grouping and sorting

20 posts, 0 answers
  1. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 15 Jun 2008 Link to this post

    Is there an easy way to allow sorting on group aggregates?

    In my application it would make sense if the user could dynamically group and then sort the grid to show the biggest group (the one that contains the most records) first.

    Regards
    Erwin
  2. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 16 Jun 2008 Link to this post

    Hello erwin,

    Thank you for writing.

    Currently, RadGridView does not offer sorting on group aggregates. We will consider adding this functionality in the future. Interestingly, you are the first customer to request such a feature. If more customers express interest in this feature, we will increase its priority for development.

    If you have any further questions, please contact me.

    Best wishes,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 17 Jun 2008 Link to this post

    Thanks Kiril,

    do you see a way to implement that programmatically? I'm new with the Rad Grid, so I would need some leads on how to resort groups based on the number of records in the group in my code.

    If I could do that dynamically in a generic way - based on the user's grouping settings - it would save me from writing a lot of specific code for re-grouping and sorting the same data set.

    Regards
    Erwin 
  5. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 17 Jun 2008 Link to this post

    Hello erwin,

    The RadGridView does not support this functionality programmatically either. I think you will not be able to implement the functionality in this way, as the groups cannot be reordered either programmatically or otherwise at this stage.

    Contact me again if you have further questions.

    Best wishes,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 18 Jun 2008 Link to this post


    Thanks for the response. I think, this could be an interesting feature for others too, once you make use of dynamic grouping. This was the first question I got when I demoed a prototype of a new GUI based on RadControls to end users.

    As a workaround I'm going for a separate window that displays the current groups based on their size (number of contained records) - Maybe even draw a pie chart based on the group info ...

    Erwin
  7. Lukasz
    Lukasz avatar
    2 posts
    Member since:
    Feb 2008

    Posted 15 Oct 2008 Link to this post

    Hi Kiril,

    We need this functionality as well. it is very important to be able to group by one column and sort by another.
    I know it may contradict sometimes because the sorting may basically force the groups to be split but i think all this can be done - it's a matter of few additional parameters to allow us to decide and give more priority either to grouping or to sorting.

    regards
    lukas
  8. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 16 Oct 2008 Link to this post

    Hello Lukasz,

    Thank you for writing.

    Currently RadGridView does not support the describing scenario. Actually you are the first customer to ask for splitting the separated groups when applying sorting. If we receive more inquiries about this, we will consider supporting such behavior.

    If you have other questions, do not hesitate to contact me again.

    Greetings,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 07 Oct 2011 Link to this post

    Hello Martin,

    I know this might be an outdated thread, but I haven't found any info on sorting  the groups. That would be a nice feature to have.

    Actually I am searching the forum for a way to prevent a grouped (and self-structured) Grid from collapsing all rows when applying a sort to a column. I have a Grid with a Parent-Child relation that is also grouped on another column (typical table with several lists of enumerator values). I have implemented a Collapse/Expand function that will open/close all groups as well as the underlying parent/child structure. I needed these to open all branches alfter loading the data into the grid.

    Is there a way to have the grid display structured/grouped item open after loading/sorting?

    Regards, Bernd
  10. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 07 Oct 2011 Link to this post

    Hello Bernd,

    As far as i know the AutoExpandGroups property should do this.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  11. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 07 Oct 2011 Link to this post

    Hello Emanuel,

    thanks for the quick response!

    Yes, AutoExpandGroups will open all groups, but the entries within the groups (which are from a self-relational table) are all closes. See here:

    What I am looking for (without having to traverse all rows and doing a
    foreach (GridViewRowInfo row in template.Rows)
       row.IsExpanded = true;
     is a property that will put all row into the table in an Expanded state, like this:


    Any Ideas?
    Regards, Bernd

  12. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 07 Oct 2011 Link to this post

    Hello Again Bernd,

    Yes, I know about this, I'm doing the same thing, as a workaround, on the DataBindingComplete event, starting a timer to expand all the rows...

    From what I've seen there is no other options on how to do this.
    I have to warn you though, if you are using an older version there were some issues with editing after a timer has expanded all the rows...

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  13. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 10 Oct 2011 Link to this post

    Hello Emanuel,

    There actually is a function
    RadGridView.MasterTemplate.ExpandAll()
    
    but that only seems to work when there is no grouping active. Do you think i should raise that as a bug?

    Another question:
    After assigning my datasource with
    EnumBindingSource.DataSource = ctx.Enums
    
    i immediately begin customizing the grid view (hiding columns, adding the grouping and self reference).
    As I am only using a small amount of test data, this works nicely.
    Now you mention waiting for the DataBindingComplete event to start a timer that will expand the rows.
    Can you enlighten me on that one? Do I have to wait for the DataBindingComplete event? Ans how long should a timer wait before starting to do things on the GridView? What things can I do immediately after assining my DataSource, what things do have to wait for the DataBindingComplete event?

    Regards,
    Bernd

    Edit: I have great problems using the DataBindingComplete Event, as it is being fired several times during InitializeComponent() and again when I set up the Grid's datasource. Any hints on that one??
    Regards, Bernd
  14. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 Oct 2011 Link to this post

    Hi Bernd,

    Thank you for writing.

    I have checked the ExpandAll method and it seems it does not work if there is an applied grouping. We will investigate this further and improve the behaviour in one of the future releases. There is no need to create a new Bug Report thread, since I have already logged this into our system. Your Telerik points have been updated for bringing this issue to our attention.

    As to your second question, I am not sure if you need a timer to expand all groups. You can do that right after the data binding. You can also overcome the current ExpandAll limitation by calling it before applying any grouping. Please consider the following code as an example:
    this.radGridView1.MasterTemplate.ExpandAll();
     
    this.radGridView1.GroupDescriptors.Add("Country", ListSortDirection.Ascending);
     
    this.radGridView1.MasterTemplate.ExpandAllGroups();

    Hope this helps. Let me know if you have any additional questions.

    All the best,
    Martin Vasilev
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  15. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 12 Oct 2011 Link to this post

    Hello Martin,

    thanks for the quick response!

    In my example the ExpandAll still does not work.
    I have created a new thread here: grid-and-bindingnavigator-not-in-sync-refresh-update-problems

    If someone will let me upload an example (see my post there), I have one ready and packed to go ...

    Regards,
    Bernd
  16. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 17 Oct 2011 Link to this post

    Hello Bernd,

    Thank you for getting back to me.

    As I already wrote, I can confirm there is an issue with ExpandAll method, which does not work properly if there is grouping applied. However, you can work-around this by removing all groups, call ExpandAll, get back the groups and call ExpandAllGroups. I have tried this in your sample project provided in another thread of yours and it looks like it works properly. Here is how I have changed the expand button's Click event:
    //hook to button expand
    private void doExpand_Click(object sender, EventArgs e)
    {
        GroupDescriptor[] descriptorArray = this.astaEnumRadGridView.GroupDescriptors.ToArray();
        this.astaEnumRadGridView.GroupDescriptors.Clear();
     
        //open tree
        //astaEnumRadGridView.MasterTemplate.ExpandAllGroups();
        //GridExpandAllRows(astaEnumRadGridView.MasterTemplate, true);
        astaEnumRadGridView.MasterTemplate.ExpandAll(); // not working when grouped!!
        //REFRESH: this is needed when gouping is active otherwise there will be no expanding
        //astaEnumBindingSource.ResetBindings(false);
     
        this.astaEnumRadGridView.GroupDescriptors.AddRange(descriptorArray);
        this.astaEnumRadGridView.MasterTemplate.ExpandAllGroups();
    }

    Please try this at your side and let me know if it is not a scenario suitable for you.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  17. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 19 Oct 2011 Link to this post

    Hello Martin,

    thanks for that explanation. It works in my code as well. I just hope the issue with ExpandAll will be fixed soon, so such a workaround will not be needed any more.

    One thing that still makes me wonder is the way the first row looks after doing an expand using your way. This is how it looks after the form has loaded:



    This is how the first row looks when the grid is expanded using your method:


    Note the funny way the selected row looks like. Is there any way to avoid this?

    Edit:
    I have exchanged all calls to
    astaEnumBindingSource.ResetBindings(false);
    
    with
    astaEnumRadGridView.MasterTemplate.Refresh();
    

    Now the selection looks ok. Sorry about that one ;-)

    Thank you again for the help on this one.

    Many regards, Bernd
  18. Bernd
    Bernd avatar
    7 posts
    Member since:
    Sep 2008

    Posted 19 Oct 2011 Link to this post

    Hello again Martin,

    just wanted to make sure you are informed that the issue with the funny looking selection is resolved (see previous entry). I was pointed into the right direction by Julian Benkov, who was answering on my support case on "Focussing a new Row when using BindingNavigator".

    Thanks again,
    Bernd
  19. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 21 Oct 2011 Link to this post

    Hi Bernd,

    I am glad you have found Julian's support helpful and thank you for making me aware of the solution with the Refresh method. Do not hesitate to contact us if you have any other questions.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  20. Leland
    Leland avatar
    7 posts
    Member since:
    Nov 2008

    Posted 31 Jan 2012 Link to this post

    I am trying to determine if any progress has been made with sorting the groups by aggregate information. Or if the sort could be applied to the group header then the aggregate data could just be placed at the front of the group header so that the biggest group can display on top.
  21. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 03 Feb 2012 Link to this post

    Hello Leland,

    Currently, this functionality is not available in RadGridView. I added it as a feature request in our Public Issue Tracking System and you can track its progress by following this link.

    Should you have other questions, we will be glad to help.
     
    Regards,
    Jack
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Back to Top
UI for WinForms is Visual Studio 2017 Ready