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 & selecting rows

I have a grid that has multi-selection turned on. It also has a single GridHierarchyLevel. Is there any way that I can prevent the user from selecting child rows?

5 Replies

AD Administrator Syncfusion Team June 16, 2004 10:25 AM

Subscribe to the SelectionsChanging event. In the handler, loop through the rows in e.Range, getting the GridBoundRecordState for each row(grid.Binder.GetRecordStateAtRowIndex). If the recordState.LevelIndex > 0 for any row, then set e.Cancel = true.


LS Lori S. Pearsall June 16, 2004 10:50 AM

Here''s an example : Parent 1 has 2 children & Parent 2 has none If the user does a multi-select (using the Shift key) of Parent 1 and Parent 2, I would like to remove the two children from the selection. Will setting e.Cancel to true cancel the entire selection? Can I alter e.Range to remove the child rows? >Subscribe to the SelectionsChanging event. In the handler, loop through the rows in e.Range, getting the GridBoundRecordState for each row(grid.Binder.GetRecordStateAtRowIndex). If the recordState.LevelIndex > 0 for any row, then set e.Cancel = true.


AD Administrator Syncfusion Team June 16, 2004 11:00 AM

No, this SelectionChanging technique will only show parent 1 since as soon as a invalid row is encountered, the selectionchanging stops to selections. If you want your user to be able to select anything, and then you remove rows you do not want to remain selected, then try the SelectionChanged event, unselecting the rows you do not want to leave selected.


LS Lori S. Pearsall June 16, 2004 11:12 AM

Thanks! One more question ... If I perform the example above and implement code in the SelectionChanged event to "unselect" the two child rows in the middle, I assume that I''ll have to modify the existing range and add another range since the desired records aren''t consecutive. Will BeginUpdate/EndUpdate be sufficient to suspend additional SelectionChanged events until I''ve performed both actions?


AD Administrator Syncfusion Team June 16, 2004 12:23 PM

No, BeginUpdate & EndUpdate affect only painting, and does not control selection events. You would have to add a flag to your class and use it to indicate when you wanted to avoid your selection code.

Loader.
Live Chat Icon For mobile
Up arrow icon