FlexGrid Group Row State

Posted by: rkane on 16 January 2018, 2:58 am EST

    • Post Options:
    • Link

    Posted 16 January 2018, 2:58 am EST

    When a FlexGrid with group rows is refreshed the IsCollapsed state is lost and all group rows are expanded. How do you restore the state after a refresh? The solution must work when you use multiple columns for grouping.

  • Posted 16 January 2018, 11:45 pm EST

    Hello,

    We could not reproduce the behavior you mentioned. The grouped rows remain in their Collapsed/Expanded state even after refreshing the grid and the IsCollapsed property also returns correct value.

    Please refer attached sample application used for same. We are using 2017v3 build version, what build version are you using?

    Thanks,

    Ruchir Agarwal

    GroupPanel.zip

  • Posted 17 January 2018, 2:57 am EST

    Here is a modified version of your sample that shows the problem. I am using 4.0.20171.549.

    GroupPanel IsCollapsed Problem.zip

  • Posted 18 January 2018, 7:11 am EST

    Hello,

    There is no direct approach for storing the states. However, we can take help of groupRow.Group.Name property that gives us the name of the group. We can then store these along with the group level in some list and while restoring match them.

    I have created a sample code snippet for this, please refer to the following:

            private void SaveExpandedRows()
            {
                DefineRows.Clear();
                for (int i = 0; i <= _flex.Rows.Count - 1; i++)
                {
                    if (_flex.Rows[i] is GroupRow)
                    {
                        if(((GroupRow)_flex.Rows[i]).IsCollapsed == true)
                        {
                            this.DefineRows.Add(((GroupRow)_flex.Rows[i]).Group.Name.ToString()+"," + ((GroupRow)_flex.Rows[i]).Level.ToString()+","+"Collapsed");
                        }
                        else
                        {
                            this.DefineRows.Add(((GroupRow)_flex.Rows[i]).Group.Name.ToString() + "," + ((GroupRow)_flex.Rows[i]).Level.ToString()+","+"Expanded");
                        }
                    }
                }
            }
            private void RestoreExpandedRows()
            {
                if(DefineRows.Count!=0 )
                {
                    for (int i = 0; i <= _flex.Rows.Count - 1; i++)
                    {
                        if (_flex.Rows[i] is GroupRow)
                        {
                            int lastRow = _flex.Rows.Count - 1;
                            int row = 0;
                            List<List<String>> tags = new List<List<String>>();
                            foreach (string data in DefineRows)
                            {
                                List<string> subTags = data.Split(',').ToList<string>();
                                tags.Add(subTags);
                            }
                            while (row <= lastRow)
                            {
                                if (_flex.Rows[row] is GroupRow)
                                {
                                    GroupRow gr = (GroupRow)_flex.Rows[row];
                                    if (gr != null)
                                    {
                                        foreach (List<String> ls in tags)
                                        {
                                            if (gr.Level.ToString() == ls[1] && gr.Group.Name.ToString() == ls[0])
                                            {
                                                if (ls[2] == "Collapsed")
                                                {
                                                    gr.IsCollapsed = true;
                                                }
                                                else
                                                {
                                                    gr.IsCollapsed = false;
                                                }
                                            }
                                        }
                                    }
                                }
                                row = row + 1;
                            }
                        }
                    }
                }
            }
    

    Hope this helps.

    Regards,

    Ruchir Agarwal

  • Posted 19 January 2018, 3:28 am EST

    That will not work. If there are multiple groups Group.Name and Group.Level will be repeated. Please provide a sample that works with multiple groups

  • Posted 22 January 2018, 10:59 pm EST

    Hello,

    Attached is a sample application implementing saving &restoring Grouped row’s state.

    Regards,

    Ruchir Agarwal

    SaveGroupState.zip

  • Posted 23 January 2018, 2:45 am EST

    That does not work. Attached are screenshot of pressing the refresh button 3 times after group by 2 categories.

    Refresh.zip

  • Posted 27 January 2018, 4:18 am EST

    Any update on this?

  • Posted 4 February 2018, 3:30 am EST

    Hello,

    This is in discussion with the development team [Tracking ID: 307049]. I will update you with the information as soon as possible.

    ~Ruchir Agarwal

  • Posted 15 February 2018, 2:51 am EST

    Any update on this?

  • Posted 15 February 2018, 6:53 pm EST

    Hi,

    The team is working over this. I have shared some further information with them, which should help in resolving quickly.

    Will get back to you once it is fixed/resolved.

    ~Ruchir Agarwal

  • Posted 22 February 2018, 8:40 pm EST

    Hello,

    We are glad to inform you that your requirement can now be fulfilled using the sample attached.

    Please verify the same and share your observations with us.

    Regards,

    Ruchir Agarwal

    SavingGroupStates.zip

  • Posted 23 February 2018, 9:25 am EST

    That does not work. Attached are images of how I set up the grid and then what it looked like after clicking on Refresh once and twice. Each should look the same but you can see that they are all different.

    Example.zip

  • Posted 26 February 2018, 12:17 am EST

    Hello,

    Thank you for sharing the images. This is by design behavior, in image ‘2.png’, the groupColor: Green’ consists only ‘Washers’ and ‘Stovesubgroups, so only the state of these sub-groups is stored. And rest all other sub-groups by default will have Expanded state. Hence, when you click ‘Refresh’ button, the sub-groups not present earlier will by default be expanded, as observed in image ‘3.png’

    Regards,

    Ruchir Agarwal

Need extra support?

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

Learn More

Forum Channels