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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GirdDataBoundGrid in hierarchical/relation view

Thread ID:

Created:

Updated:

Platform:

Replies:

29797 Jun 2,2005 09:13 PM UTC Jun 4,2005 04:02 PM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 2, 2005 09:13 PM UTC

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

Administrator [Syncfusion]
Replied On June 3, 2005 12:26 AM UTC

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.

Administrator [Syncfusion]
Replied On June 3, 2005 03:41 PM UTC

I really appreciate your help. Thanks, Scott

Administrator [Syncfusion]
Replied On June 3, 2005 09:07 PM UTC

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

Administrator [Syncfusion]
Replied On June 3, 2005 09:44 PM UTC

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

Administrator [Syncfusion]
Replied On June 4, 2005 02:45 AM UTC

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";

Administrator [Syncfusion]
Replied On June 4, 2005 04:02 PM UTC

Works like charm. thanks,

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;