This is a migrated thread and some comments may be shown as answers.

grouping and sorting

19 Answers 440 Views
GridView
This is a migrated thread and some comments may be shown as answers.
erwin
Top achievements
Rank 1
Veteran
Iron
erwin asked on 15 Jun 2008, 07:05 AM
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

19 Answers, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 16 Jun 2008, 01:28 PM
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
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 17 Jun 2008, 08:57 AM
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 
0
Kiril
Telerik team
answered on 17 Jun 2008, 03:43 PM
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
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 18 Jun 2008, 08:41 PM

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
0
Lukasz
Top achievements
Rank 1
answered on 15 Oct 2008, 01:11 PM
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
0
Martin Vasilev
Telerik team
answered on 16 Oct 2008, 12:11 PM
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.
0
Bernd
Top achievements
Rank 1
answered on 07 Oct 2011, 10:02 AM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Oct 2011, 10:05 AM
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
0
Bernd
Top achievements
Rank 1
answered on 07 Oct 2011, 11:52 AM
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

0
Emanuel Varga
Top achievements
Rank 1
answered on 07 Oct 2011, 12:30 PM
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
0
Bernd
Top achievements
Rank 1
answered on 10 Oct 2011, 09:18 AM
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
0
Martin Vasilev
Telerik team
answered on 12 Oct 2011, 12:15 PM
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.

0
Bernd
Top achievements
Rank 1
answered on 12 Oct 2011, 04:41 PM
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
0
Martin Vasilev
Telerik team
answered on 17 Oct 2011, 01:46 PM
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.

0
Bernd
Top achievements
Rank 1
answered on 19 Oct 2011, 08:46 AM
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
0
Bernd
Top achievements
Rank 1
answered on 19 Oct 2011, 09:07 AM
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
0
Martin Vasilev
Telerik team
answered on 21 Oct 2011, 03:57 PM
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.

0
Leland
Top achievements
Rank 1
answered on 31 Jan 2012, 11:27 PM
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.
0
Jack
Telerik team
answered on 03 Feb 2012, 04:18 PM
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).

Tags
GridView
Asked by
erwin
Top achievements
Rank 1
Veteran
Iron
Answers by
Kiril
Telerik team
erwin
Top achievements
Rank 1
Veteran
Iron
Lukasz
Top achievements
Rank 1
Martin Vasilev
Telerik team
Bernd
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Leland
Top achievements
Rank 1
Jack
Telerik team
Share this question
or