This is a migrated thread and some comments may be shown as answers.

Hide rowdetail when multiple rows are selected

3 Answers 27 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Veteran
Randy asked on 16 Aug 2018, 07:53 AM

I have a RadGridView with RowDetailsVisibilityMode set to "VisibleWhenSelected" and SelectionMode as "Extended". It works great when single row is selected. But when multiple rows are selected, the row details of each row will all be shown which makes the grid looks in a jumble. Is it possible to not show row detail when multiple row are selected but keep show row detail when single row is selected?

I'm using 2014.1.411.45 and MVVM. Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 20 Aug 2018, 02:59 PM
Hello Randy,

What I can propose you as a possible solution would be to use the SelectionChanging event of RadGridView and set its RowDetailsVisibilityMode property based on the count of the selected items. Please, take a look at the code snippet below.
private void clubsGrid_SelectionChanging(object sender, SelectionChangingEventArgs e)
      {
          if (this.clubsGrid.SelectedItems.Count > 0)
          {
              this.clubsGrid.RowDetailsVisibilityMode = GridViewRowDetailsVisibilityMode.Collapsed;
          }
      }

In order to avoid using code-behind and keep the MVVM environment intact, you can benefit from the EventToCommandBehavior mechanism.

Would such an approach be working for you?

Regards,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Randy
Top achievements
Rank 1
Veteran
answered on 21 Aug 2018, 03:07 AM

Hi Stefan,

Thanks for the advice. This approach does works. But it seems when SelectionChanging raised the selected items are still as the same count as before the selection, which may need take AddedItems and RemovedItems in the SelectionChangingEventArg into consideration to make sure having accurate count. So I ended up with SelectionChanged event instead, where selected items count reflects what you actually selected.

Still, thank you very much for the inspiration.

0
Stefan
Telerik team
answered on 21 Aug 2018, 03:09 PM
Hello Randy,

Thank you for the update. I am happy that you have found the solution for your requirement.

Indeed, your observations are correct. You can either use the AddedItems of the event arguments of the SelectionChanging event, or the SelectionChanged one as at the state when it is raised the selection has already passed. Please, excuse me for overlooking this.

All the best,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Randy
Top achievements
Rank 1
Veteran
Answers by
Stefan
Telerik team
Randy
Top achievements
Rank 1
Veteran
Share this question
or