MultiColumn Headers Design for WebGrid in Infragistics

Source: Internet
Author: User

Generally, when designing a Grid multi-row header, we may first consider using Repeater or DataList, but now we can use Infragistics's WebGrid to easily implement this function, the implementation is as follows:

The code for implementing such a header is as follows:
Add the following code to the Grid InitializeLayout event:

//
// Design multiple headers
//
Private void ut_grid105_InitializeLayout (object sender, Infragistics. WebUI. UltraWebGrid. LayoutEventArgs e)
{
Foreach (Infragistics. WebUI. UltraWebGrid. ultratedcolumn c in e. Layout. Bands [0]. Columns)
{
C. Header. RowLayoutColumnInfo. OriginY = 1;
}

// Create a new header and set its display name
Infragistics. WebUI. UltraWebGrid. ColumnHeader ch = new ColumnHeader (true );
Ch. Caption = "purchase volume ";
// Set the start position of the Y axis
Ch. RowLayoutColumnInfo. OriginY = 0;
// Set the start position of the X axis
Ch. RowLayoutColumnInfo. OriginX = 4;
// Set the number of columns in the X axis of the header.
Ch. RowLayoutColumnInfo. SpanX = 2;

// Add the header to our Grid.
E. Layout. Bands [0]. HeaderLayout. Add (ch );

Infragistics. WebUI. UltraWebGrid. ColumnHeader attributes = new ColumnHeader (true );
Ch1.Caption = "consumption ";
Ch1.RowLayoutColumnInfo. OriginY = 0;
Ch1.RowLayoutColumnInfo. origtables = 6;
Ch1.RowLayoutColumnInfo. SpanX = 5;

E. Layout. Bands [0]. HeaderLayout. Add (scheme );


Foreach (Infragistics. WebUI. UltraWebGrid. ultratedcolumn c in e. Layout. Bands [0]. Columns)
{
If (c. Key! = "A02" & c. Key! = "A03" & c. Key! = "A04" & c. Key! = "A05" & c. Key! = "A06" & c. Key! = "A07" & c. Key! = "A08 ")
{
C. Header. RowLayoutColumnInfo. OriginY = 0;
C. Header. RowLayoutColumnInfo. SpanY = 2;
}
}

}

Of course, we can also fix a certain column or several columns. The Code is as follows:

// Fixed column
E. Layout. Bands [0]. Columns. FromKey ("zbmc"). Header. Fixed = true;
E. Layout. Bands [0]. Columns. FromKey ("jldw"). Header. Fixed = true;
E. Layout. Bands [0]. Columns. FromKey ("zbdm"). Header. Fixed = true;

The result is that when we drag the scroll bar horizontally, the fixed columns do not move accordingly. This is suitable for some online forms (the table is too long.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.