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

GirdDataBoundGrid in hierarchical/relation view

I have some questions about using GirdDataBoundGrid. I am using GirdDataBoundGrid instance in a hierarchical/relation view. I have a column in grid which has style as ‘Checkbox’. what I am trying to do it that, when I check the checkbox for a upper level row which has some child rows then ‘checkbox’ should be check/uncheck for all the Child rows based on the upper level value. I believe that I have to use GetRecordStateAtRowIndex function. I have to some questions regarding this. #1 Which grid event should I use do that? or should i create a method to do all this. #2 How do I get current checked row? #3 How do I find that current row has some child rows? And how do I loop thru each child? #4 How do I find that current is a child row? #5 If current row is a child then how do I find the parent row of current child? This is needed if user uncheck the ‘checkbox’ for one of the child then parent row ‘checkbox’ can’t be checked. #6 In case of multiple levels, should I use the recursion? Please advise the best way to achieve this. Regrads, Scott

6 Replies

AD Administrator Syncfusion Team June 2, 2005 07:26 PM

1) I would first try the grid.CheckBoxClick event. 2)In that event, use grid[e.RowIndex,e.ColIndex].CellValue. Now this value will be the opposite value from the new value so you will have to negate it to get the new value. 3)You get this information from the GridBoundrecordState for this e.RowIndex. It has a HasChildList and a ChildList property.You can loop through the objects in the ChildList and cast them to DataRowView objects to work with them. 4)You get this information from the GridBoundrecordState for this e.RowIndex. The Table property (if not null) is the parent list for the row. 5) The GridBoundRecordState has a Position property that gives the index of this record it its parent list (the Table property). If you subtract this Position value from the e.RowIndex and then subtract 1 more, it should give you the rowIndex of the parent record. 6)Probably.


AD Administrator Syncfusion Team June 3, 2005 10:41 AM

I really appreciate your help. Thanks, Scott


AD Administrator Syncfusion Team June 3, 2005 04:07 PM

Clay, I am having small problem with checkbox type column. Checkboxes are not showing up on each level. I am using the following code this.gridBoundColumn3.StyleInfo.CellType = "CheckBox"; this.gridBoundColumn3.StyleInfo.CellValueType = typeof(short); this.gridBoundColumn3.StyleInfo.CheckBoxOptions.CheckedValue = "1"; this.gridBoundColumn3.StyleInfo.CheckBoxOptions.UncheckedValue = "0"; private void Form1_Load(object sender, System.EventArgs e) { DataTable parentTable = GetParentTable(); DataTable childTable = GetChildTable(); DataTable grandChildTable = GetGrandChildTable(); DataSet ds = new DataSet(); ds.Tables.AddRange(new DataTable[]{parentTable, childTable, grandChildTable}); DataRelation parentToChild = new DataRelation("ParentToChild", parentTable.Columns["parentID"], childTable.Columns["ParentID"]); DataRelation childToGrandChild = new DataRelation("ChildToGrandChild", childTable.Columns["childID"], grandChildTable.Columns["ChildID"]); ds.Relations.AddRange(new DataRelation[]{parentToChild, childToGrandChild }); this.gridDataBoundGrid1.DataSource = ds; this.gridDataBoundGrid1.DataMember = parentTable.TableName; this.gridDataBoundGrid1.ShowTreeLines = true; this.gridDataBoundGrid1.EnableAddNew = false; GridHierarchyLevel level0 = this.gridDataBoundGrid1.Binder.RootHierarchyLevel; GridHierarchyLevel level1 = this.gridDataBoundGrid1.Binder.AddRelation("ParentToChild"); GridHierarchyLevel level2 = this.gridDataBoundGrid1.Binder.AddRelation("ChildToGrandChild"); } Third column has either 1 or 0 in each DataTable. Please help me. Scott


AD Administrator Syncfusion Team June 3, 2005 04:44 PM

I just created a sample and having same problem. Please find the attached sample. Please do help. gridchckbox_2276.zip


AD Administrator Syncfusion Team June 3, 2005 09:45 PM

Each level has its own set of GridBoundColumns (so the styles can vary from level to level). So, you also have to set the styles at level 1 and level 2. style = level1.InternalColumns[3].StyleInfo; style.CellType = "CheckBox"; style.CellValueType = typeof(int); style.CheckBoxOptions.CheckedValue = "1"; style.CheckBoxOptions.UncheckedValue = "0"; style = level2.InternalColumns[3].StyleInfo; style.CellType = "CheckBox"; style.CellValueType = typeof(int); style.CheckBoxOptions.CheckedValue = "1"; style.CheckBoxOptions.UncheckedValue = "0";


AD Administrator Syncfusion Team June 4, 2005 11:02 AM

Works like charm. thanks,

Loader.
Live Chat Icon For mobile
Up arrow icon