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

Traversing in hierarchial databound grid?

I am using hierarchial databound grid. I want to read the value of one cell in child table and then according to that value I want to set the background color property of row in child table as well as background color property of row in parent table. How can I achieve this?

5 Replies

Administrator July 8, 2004 04:48 PM UTC

In a griddataboundgrid, you cannot just set a row style. You have to handle PrepareViewStyleInfo and in the handler, set the colors dynamically on demand. There are a couple of KBs on this. Here is a sample that uses PrepareViewStyleInfo and CurrentCellCommitChanges to do what you described. If you type a color name like red or blue in the Name column of the grid, the backcilor of the row and its parent will change to that color. The sample stores the backColors in a Hashtable with a key based on the primary id for the row (something that does not change). The change is checked in the CurrentCellCommitChanges event. HierarchyColorRows_3834.zip

UM Umangi July 8, 2004 05:21 PM UTC

Hi Clay, Thanks for such quick reply.The function for finding parentrow is helpful. But still I will need to traverse through the child table of grid. I dont set the colors of grid on basis of current cell value but There is one column Called ''Unread'' in child table. That contains boolean value. If the data in that column is true I want to change the color of row as well as parent row.Could u pls help? Umangi >In a griddataboundgrid, you cannot just set a row style. You have to handle PrepareViewStyleInfo and in the handler, set the colors dynamically on demand. There are a couple of KBs on this. > >Here is a sample that uses PrepareViewStyleInfo and CurrentCellCommitChanges to do what you described. If you type a color name like red or blue in the Name column of the grid, the backcilor of the row and its parent will change to that color. The sample stores the backColors in a Hashtable with a key based on the primary id for the row (something that does not change). The change is checked in the CurrentCellCommitChanges event. > > > >HierarchyColorRows_3834.zip > >

Administrator July 8, 2004 06:09 PM UTC

You access both the parent table and the child table through the GridBoundRecordState for the row. You can then iterate though the dataviews. rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(row); DataView childDataView = rs.ChildList as DataView; DataView parentDataView = rs.Table as DataView;

UM Umangi July 8, 2004 07:13 PM UTC

While iterating through DataView I have data of grid but that time I dont have track of GridStyleInfo.So I can check the variable but then not set the color of row.I need both at a time. Something similar to GridRowCollection. Can u tell me how can I get GridRowCollection for my Grid which is binded to data. Thanks Umangi >You access both the parent table and the child table through the GridBoundRecordState for the row. You can then iterate though the dataviews. > > >rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(row); > DataView childDataView = rs.ChildList as DataView; > DataView parentDataView = rs.Table as DataView; >

Administrator July 8, 2004 07:18 PM UTC

There is no GridRowCollection in a GriddataBoundGrid. There is no way to get at a GridStyleInfo object for a row in a GridDataBoudGrid because that grid does not maintain such a collection. Here is a KB. http://www.syncfusion.com/Support/article.aspx?id=561 In the sample I did above, it colors rows in a GridDataBoundGrid using PrepareViewStyleInfo. You will have to do something similar. You will have to maintain a collection of backcolors (or styles or whatever you need), and then use the backcolors or styles in PrepareViewStyleInfo to color the rows on demand. That is what the sample above does.
Loader.
Live Chat Icon For mobile
Up arrow icon