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

GridHierarchyLevel - would like to vary default row heights

I have a grid that I''m in the process of adding a single GridHierarchyLevel to. The rows represented by the "master" record are fairly tall - DefaultRowHeight = 48 to be able to see small images and wrapped text. The new "child" that I''m going to add will display just a filename so the default row height of 17 would be optimal for me. Ideally, I''d like to set up two different default row heights. I know that I could alter the row heights in PrepareViewStyleInfo, but I need to give the user the ability to change them. Is there a way that I can do this? A couple of other related to GridHierarchyLevel - Is there a way to tell whether any of the "child" records are being displayed or if all of them are collapsed? Is there an event that corresponds to when the user expands or collapses a node? Are the "child" records always present in the grid''s row collection? For example, RowIndex = 2 would be my first child record if it''s parent is expanded - will RowIndex = 2 ALWAYS be the first child record regardless? Thanks for your help!

7 Replies

AD Administrator Syncfusion Team June 7, 2004 02:56 PM UTC

>Ideally, I''d like to set up two different default row heights. I know that I could alter the row heights in PrepareViewStyleInfo, but I need to give the user the ability to change them. Is there a way that I can do this? > In a grid.Model.QueryRowHeights event handler, you can get the GridBoundRecordState GridBoundRecordState rs = grid.Binder.Binder.GetRecordStateAtRowIndex(e.Index); Then you can set e.Size base on rs.LevelIndex and set e.Handled = true. This woul dlet you size the parent row one way an dteh child row another. But, if you want to allow your user to size things, these actions will be in conflcit with automatically sizing things in QueryRowHieght. To handle this, youwoul dhave to maintain a list of explicitly set rowheights and use that list to set the rowheight in QueryRowHeight if one of the expleictly set rows is being requested. This would take a little work. >Is there a way to tell whether any of the "child" records are being displayed or if all of them are collapsed? > There is a grid.IsExpandedAtRowIndex method that you can used to test if a row is expanded. >Is there an event that corresponds to when the user expands or collapses a node? > There are grid.RowExpanding/RowExpanded and grid.RowCollapsing/RowCollapsed events. >Are the "child" records always present in the grid''s row collection? For example, RowIndex = 2 would be my first child record if it''s parent is expanded - will RowIndex = 2 ALWAYS be the first child record regardless? > The child rows are only in the grid when their parent row is expanded. They are not always present.


LS Lori S. Pearsall June 7, 2004 05:45 PM UTC

>In a grid.Model.QueryRowHeights event handler, you can get the GridBoundRecordState > >GridBoundRecordState rs = grid.Binder.Binder.GetRecordStateAtRowIndex(e.Index); > >Then you can set e.Size base on rs.LevelIndex and set e.Handled = true. This woul dlet you size the parent row one way an dteh child row another. But, if you want to allow your user to size things, these actions will be in conflcit with automatically sizing things in QueryRowHieght. Is QueryRowHeight all or nothing? If I use the following code to try to resize just the child rows ... GridBoundRecordState rs = this.gridEvents.Binder.GetRecordStateAtRowIndex(e.Index); if (rs != null && rs.LevelIndex != 0) { e.Size = 17; e.Handled = true; } I''m unable to resize any of the rows. I also seem to be unable to invoke this method in the base class.


AD Administrator Syncfusion Team June 7, 2004 06:01 PM UTC

Here is sample that sizes level 1 rows in QueryRowHeight, but still lets you manually size level 0 and level 2 rows from the UI. GDBGHierarchRowHeight_6068.zip


LS Lori S. Pearsall June 7, 2004 07:23 PM UTC

Many thanks - refreshing in the RowCollapsed & RowExpanded events was what I was missing. I have one last question and this one is trivial. I size the +/- column (ColWidths[1]) down to take up less room. This causes my record selector column to be narrowed as well. I try to reset the width of the record selector column (ColWidths[0]) to what it should be, but nothing has any effect. I have AllowResize to fit set to false.


AD Administrator Syncfusion Team June 7, 2004 07:58 PM UTC

I added these lines at the end of the formload in the sample from above, and column 1 seems to resize without affecting column 0. this.gridDataBoundGrid1.AllowResizeToFit = false; this.gridDataBoundGrid1.Model.ColWidths[1] = 15; Does this not work for you?


LS Lori S. Pearsall June 7, 2004 11:20 PM UTC

No, actually not. I set the record selector (ColWidths[0]) to 17 and once I set ColWidths[1](hierarchy +/-) to 17, the record selector column gets compressed to 12. There''s no effect if I try to reset it to 17 again.


AD Administrator Syncfusion Team June 8, 2004 04:33 AM UTC

This code in the above sample shows no problem for me, and the colwidths do not change after the original setting. this.gridDataBoundGrid1.AllowResizeToFit = false; this.gridDataBoundGrid1.Model.ColWidths[0] = 17; this.gridDataBoundGrid1.Model.ColWidths[1] = 17; I suspect in your code, there is something (maybe a grid.Model.Colwidths.ResizeToFit call or some code in a QueryColWidths handler) that is changing the widths after you have set them. One way to try to spot this is to add a this.gridDataBoundGrid1.Model.ColWidthsChanging event handler and see if/where column 0 is being set to size 12. If you can post a sample project showing the problem (maybe modify the above sample to show it), we can try to spot something here.

Loader.
Live Chat Icon For mobile
Up arrow icon