Xamarin.Forms Grouping

Posted by: nort.skype on 11 April 2021, 11:01 pm EST

    • Post Options:
    • Link

    Posted 11 April 2021, 11:01 pm EST - Updated 3 October 2022, 10:47 pm EST

    How can I make a group in a group…?

    Examples:





  • Posted 12 April 2021, 7:47 pm EST

    Hi Andrew

    Grouping in FlexGrid is supported through ISupportGrouping. ISupportGrouping has GroupAsync method which accepts the array of GroupDescription. Provide the groupPath as the required column.

     var data = Customer.GetCustomerList(100);
                _dataCollection = new C1DataCollection<Customer>(data);
    
                var grouping = _dataCollection as ISupportGrouping;
                await  grouping.GroupAsync(new GroupDescription[] { new GroupDescription("Country"), new GroupDescription("FirstName") });
                grid.ItemsSource = (System.Collections.IEnumerable)grouping;
               
                grid.MinColumnWidth = 85;
    

    For reference please have a look at the attached screenshot, also for implementation you can refer to the “Grouping” sample of the attached “FlexGrid101” sample.

    Please let me know if you need any other help.

    ThanksFlexGrid101.zip[img]https://gccontent.blob.core.windows.net/forum-uploads/file-87c10386-1856-4153-8cee-8134f0b69f98.png[/img]

  • Posted 13 April 2021, 5:27 pm EST

    Thank you so much!

    Is there an alternative to this line:

    grid.ItemsSource = (System.Collections.IEnumerable)grouping;
    

    I did a test grouping with:

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/picker/

    When I choose a column for grouping in the picker, I have to wait a very long time.

    App speed is very important to our company. Please help me find an alternative to make the grouping work faster.

    I think, grouping work for a very long time due to the constant replacement of ItemsSource

  • Posted 13 April 2021, 6:40 pm EST

    Hi Andrew

    Yes, we can remove the casting of ISupportGrouping to IEnumerable. Set the ItemSource of the FlexGrid and apply grouping on the DataCollection of the FlexGrid.

    public Grouping()
            {
                InitializeComponent();
    
                this.Title = AppResources.GroupingTitle;
     
               
    
                var data = Customer.GetCustomerList(100);
                grid.ItemsSource = data;
                grid.MinColumnWidth = 85;
    
                var task = UpdateVideos();
            }
    
            private async Task UpdateVideos()
            {
                var grouping = grid.DataCollection as ISupportGrouping;
                await  grouping.GroupAsync(new GroupDescription[] { new GroupDescription("Country"), new GroupDescription("FirstName") });   
            }
    

    For reference please have a look at the “Grouping” sample of the attached FlexGrid101 sample.

    Please let me know if you need any other help.

    Thanks

    FlexGrid101.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels