The ColumnSet feature is not limited on RootTable only. You can also configure the Child Table to use ColumnSet Layout while still having the rest features to work in harmony.
Creating Hierarchical ColumnSet is similar with the common process of creating normal HierarchicalStructure of the grid.
These are the guides :
- Bind the RootTable and ChildTable using ISDatasource.
- Then create the ColumnSet RootTable column.
-
C# Copy Code private void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { if(!IsPostBack) { CreateColumnSet(); } }
- Creating ColumnSet ChildTable Column.
-
C# Copy Code protected void MainGrid_InitChildDataSource(object sender, ISNet.WebUI.WebGrid.ChildTableDataSourceEventArgs e) { CreateChildColumnSet(); }
- This is the code for ColumnSet RootTable :
-
C# Copy Code private void CreateColumnSet() { // Creating ColumnSet 0 and add into WebGrid WebGrid1.RootTable.RowLayout = RowLayoutMode.ColumnSet; WebGridColumnSet oColumnSet = new WebGridColumnSet(); oColumnSet.Caption = "ColumnSet0"; oColumnSet.Name = "ColumnSet0"; oColumnSet.ColumnCount = 4; WebGrid1.RootTable.ColumnSets.Add(oColumnSet); //Creating RowLayout Object WebGridRowLayoutCollection oRowLayouts = oColumnSet.Layout; WebGridRowLayout oRowLayout = new WebGridRowLayout(); WebGrid1.RootTable.ColumnSetSettings.RowCount=1; oRowLayout.Col = 0; oRowLayout.Row = 0; oRowLayout.ColumnMember = "CompanyName"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 1; oRowLayout.Row = 0; oRowLayout.ColumnMember = "ContactName"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 2; oRowLayout.Row = 0; oRowLayout.ColumnMember = "ContactTitle"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 3; oRowLayout.Row = 0; oRowLayout.ColumnMember = "Address"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 0; oRowLayout.Row = 1; oRowLayout.ColumnMember = "City"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 1; oRowLayout.ColSpan = 3; oRowLayout.Row = 1; oRowLayout.ColumnMember = "Country"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Spanned = RowLayoutSpan.Column; oRowLayout.Col = 1; oRowLayout.Row = 1; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Spanned = RowLayoutSpan.Column; oRowLayout.Col = 2; oRowLayout.Row = 1; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Spanned = RowLayoutSpan.Column; oRowLayout.Col = 3; oRowLayout.Row = 1; oRowLayouts.Add(oRowLayout); WebGridRowLayout oRowLayout1; oRowLayout1 = new WebGridRowLayout(); oRowLayout1.Col = 0; oRowLayout1.Row = 0; oRowLayout1.RowSpan = 2; oRowLayout1.ColumnMember = "Fax"; oRowLayouts.Add(oRowLayout1); oRowLayout1 = new WebGridRowLayout(); oRowLayout1.Col = 1; oRowLayout1.Row = 0; oRowLayout1.RowSpan = 2; oRowLayout1.ColumnMember = "Region"; oRowLayouts.Add(oRowLayout1); oRowLayout1 = new WebGridRowLayout(); oRowLayout1.Col = 0; oRowLayout1.Row = 1; oRowLayouts.Add(oRowLayout1); oRowLayout1 = new WebGridRowLayout(); oRowLayout1.Col = 1; oRowLayout1.Row = 1; oRowLayouts.Add(oRowLayout1); }
- This is the ChildTable ColumnSet code :
-
C# Copy Code private void CreateChildColumnSet() { WebGrid1.RootTable.ChildTables[0].RowLayout = RowLayoutMode.ColumnSet; WebGridColumnSet oColumnSet = new WebGridColumnSet(); oColumnSet.Caption = "ColumnSet2"; oColumnSet.Name = "ColumnSet2"; oColumnSet.ColumnCount = 3; WebGrid1.RootTable.ChildTables[0].ColumnSetSettings.RowCount=3; WebGrid1.RootTable.ChildTables[0].ColumnSets.Add(oColumnSet); WebGridRowLayoutCollection oRowLayouts = oColumnSet.Layout; WebGridRowLayout oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 0; oRowLayout.Row = 0; oRowLayout.ColumnMember = "OrderID"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 1; oRowLayout.Row = 0; oRowLayout.ColumnMember = "OrderDate"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 2; oRowLayout.Row = 0; oRowLayout.ColumnMember = "EmployeeID"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 0; oRowLayout.Row = 1; oRowLayout.ColumnMember = "CustomerID"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 1; oRowLayout.Row = 1; oRowLayout.ColumnMember = "Freight"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 2; oRowLayout.Row = 1; oRowLayout.ColumnMember = "RequiredDate"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 0; oRowLayout.Row = 2; oRowLayout.ColumnMember = "ShipVia"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 1; oRowLayout.Row = 2; oRowLayout.ColumnMember = "ShippedDate"; oRowLayouts.Add(oRowLayout); oRowLayout = new WebGridRowLayout(); oRowLayout.Col = 2; oRowLayout.Row = 2; oRowLayout.ColumnMember = "ShipCountry"; oRowLayouts.Add(oRowLayout); }
Overview
Getting Started
WebGrid Features Overview
Other Resources
Walkthrough Topics
How-to Topics