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.
Unfortunately, activation email could not send to your email. Please try again.

Sf Listview: Collapse all other groups when one is expanded

Thread ID:

Created:

Updated:

Platform:

Replies:

130303 May 5,2017 02:17 AM May 8,2017 04:29 AM Xamarin.Forms 1
loading
Tags: SfListView
bg
Asked On May 5, 2017 02:17 AM

Hi,

As the title suggests , how can I collapse all but the selected group?

Thanks.

Dinesh Babu Yadav [Syncfusion]
Replied On May 8, 2017 04:29 AM

Hi Customer,

Thank you for using Syncfusion Products.
 
 
We have checked the reported query “Need to Collapse all other groups when one group is expanded” at our end and we would like to let you know that the reported requirement can be achieved by using GroupExpanding event which will be triggered whenever a particular group is being expanded and the particular selected group can be get from GroupExpandCollapseChangingEventArgs by which you can compare and collapse all other groups and expand the particular selected group as highlighted in the below code snippets. 
 
Code Example[C#]: 
private void ListView_GroupExpanding(object sender, GroupExpandCollapseChangingEventArgs e) 
{ 
  if (e.Groups.Count > 0) 
  { 
    var group = e.Groups[0]; 
    if (expandedGroup == null || group.Key != expandedGroup.Key) 
    { 
      foreach (var otherGroup in listView.DataSource.Groups) 
      { 
        if (group.Key != otherGroup.Key) 
        { 
          listView.CollapseGroup(otherGroup); 
        } 
      } 
      expandedGroup = group; 
      listView.ExpandGroup(expandedGroup); 
    } 
 } 
} 
 
For your assistance we have prepared a working sample and you can download it from the below link. 
 
 
Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;