Unplanned
Last Updated: 21 Jul 2022 07:41 by ADMIN
Christopher
Created on: 14 Jul 2022 13:31
Category: GridView
Type: Feature Request
0
Implement IsExpandedBinding when using row details template
We are using telerik:RadGridView.RowDetailsTemplate in our GridView and we need the ability to expand or contract all rows at the press of a button.  As in the demo code under Hierarchy, we need to do this from our ViewModel.  Can the IsExpandedBinding be implemented for this use case in addition to when using hierarchical data?  
1 comment
ADMIN
Stenly
Posted on: 21 Jul 2022 07:41

Hello Christopher,

Currently, the IsExpandedBinding and IsExpandableBinding properties are only supported when using GridViewTableDefinition. However, I think that you could still achieve the desired expand/collapse logic of all rows when a button is clicked. This could be done by utilizing the RowDetailsVisibilityMode property of the RadGridView control. A property of type GridViewRowDetailsVisibilityMode could be defined inside your view model, which could be bound to the mentioned RadGridView property, and via a command, you could change its value.

The following code snippets show a sample implementation of these suggestion's implementation:

public class MainViewModel : ViewModelBase
{
    private GridViewRowDetailsVisibilityMode visibilityMode;

    public MainViewModel()
    {
        this.VisibilityMode = GridViewRowDetailsVisibilityMode.Collapsed;
        this.ChangeVisibilityModeCommand = new DelegateCommand(OnCmdExecuted);
    }
	
    public GridViewRowDetailsVisibilityMode VisibilityMode
    {
        get { return visibilityMode; }
        set { visibilityMode = value; this.OnPropertyChanged(nameof(this.VisibilityMode)); }
    }
    public ICommand ChangeVisibilityModeCommand { get; set; }

    private void OnCmdExecuted(object obj)
    {
        if (this.VisibilityMode == GridViewRowDetailsVisibilityMode.Collapsed)
        {
            this.VisibilityMode = GridViewRowDetailsVisibilityMode.Visible;
        }   
        else if (this.VisibilityMode == GridViewRowDetailsVisibilityMode.Visible)
        {
            this.VisibilityMode = GridViewRowDetailsVisibilityMode.Collapsed;
        }
    }
}
<Grid>
    <Grid.DataContext>
        <local:MainViewModel/>
    </Grid.DataContext>
    <telerik:RadGridView Name="gridview" RowDetailsVisibilityMode="{Binding VisibilityMode}"/>
</Grid>

The following result is present on my end when the ChangeVisibilityModeCommand is executed:

I have also attached a sample application, so, could you give it a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Attached Files: