We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Adding columns to GridHierarchyLevel does not work?

Attached is simple project, dataset with 2 small related tables. I am trying to manually configure columns for nested tables in DataBoundGrid, however if I manually add column to GridHierarchyLevel, the data is not displayed (even though header has correct text). Quick analysis shows that generated Internal Column for nested table is missing the Property Descriptor (parent table is generated and displayed properly), even though I do explicitly call Binder.InitializeColumns(); Please help ? sample_5155.zip

1 Reply

AD Administrator Syncfusion Team September 15, 2004 05:44 AM UTC

Instead of trying to populate level.GridBoundCOlumns with new GridBoundColumns, try using level.LayoutColumns. This will just use teh columns that are already there and move them into level.GridBoundColumns. Below is your formload with this done. It displays 1 column at both teh parent and child level for me. private void Form1_Load(object sender, System.EventArgs e) { dataset11.Loadtag_Record.AddLoadtag_RecordRow(1, "123", 1, 1); dataset11.Loadtag_Record.AddLoadtag_RecordRow(2, "456", 1, 1); dataset11.Loadtag_Data.AddLoadtag_DataRow(dataset11.Loadtag_Record[0], 1, "1"); dataset11.Loadtag_Data.AddLoadtag_DataRow(dataset11.Loadtag_Record[0], 2, "2"); dataset11.Loadtag_Data.AddLoadtag_DataRow(dataset11.Loadtag_Record[1], 3, "3"); dataset11.AcceptChanges(); gridDataBoundGrid1.DataSource = dataset11.Loadtag_Record; ////// Syncfusion.Windows.Forms.Grid.GridHierarchyLevel lvl = gridDataBoundGrid1.Binder.AddRelation(dataset11.Loadtag_Record.ChildRelations[0].RelationName); ////// Syncfusion.Windows.Forms.Grid.GridBoundColumn parentColumn = new Syncfusion.Windows.Forms.Grid.GridBoundColumn(); ////// parentColumn.MappingName = "OrderID"; ////// parentColumn.HeaderText = "OrderID"; ////// gridDataBoundGrid1.GridBoundColumns.Add(parentColumn); // Without next 4 lines grid works, but displays all 4 columns, // What to do if I want only one? ////// Syncfusion.Windows.Forms.Grid.GridBoundColumn childColumn = new Syncfusion.Windows.Forms.Grid.GridBoundColumn(); ////// childColumn.MappingName = "LoadNumber"; ////// childColumn.HeaderText = "LoadNumber"; ////// lvl.GridBoundColumns.Add(childColumn); Syncfusion.Windows.Forms.Grid.GridHierarchyLevel lv0 = this.gridDataBoundGrid1.Binder.RootHierarchyLevel; lv0.LayoutColumns(new string[]{"OrderID"}); Syncfusion.Windows.Forms.Grid.GridHierarchyLevel lvl = gridDataBoundGrid1.Binder.AddRelation(dataset11.Loadtag_Record.ChildRelations[0].RelationName); lvl.LayoutColumns(new string[] {"LoadNumber"}); ////// gridDataBoundGrid1.Binder.InitializeColumns(); gridDataBoundGrid1.Refresh(); }

Loader.
Live Chat Icon For mobile
Up arrow icon