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

Preventing the group from being collapsed.

Hi,

I have a requirement where some of the group should not be collapsible, so I have added the below code on OnGroupCollapsed method where I am checking if the group is "Component #1" then we are setting the group.IsExpand=True.

private void SfDataGrid_OnGroupCollapsed(object sender, GroupChangedEventArgs e)

{

if (e.Group.Key.Equals("Component #1"))

{

e.Group.IsExpanded = true;

}

}

With this above code what we are noticing is that for the group "Component #1" when user clicks on collapse the group does not collapse [As needed] but what i also notice is that some of the rows down below are getting removed and we are getting an ArgumentOutofRangeException.

Can you please let me know why we are getting this exception when we are not deleting any row here. Attached is the sample application.

Thanks


Attachment: SampleGrid_774f2988.7z

1 Reply

SR Sivakumar R Syncfusion Team February 29, 2016 03:54 AM UTC

Hi Pruthvi,

You can achieve your requirement by handling GroupCollapsing event instead of GroupCollapsed event.

this.datagrid.GroupCollapsing += Datagrid_GroupCollapsing;

private void Datagrid_GroupCollapsing(object sender, GroupChangingEventArgs e)

{

    if (e.Group.Key.Equals("Component #1"))

    {

        e.Cancel = true;

    }
}



Thanks,
Sivakumar

Loader.
Up arrow icon