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

[Solved] RadGrid GroupByField sorting problem

7 Answers 452 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 1
Andrei asked on 14 May 2008, 07:22 PM
Hi,

I am having an issue with the GroupByField functionality of RadGrid where it basically cancels any previous sorting and forces the radgrid to sort based on the field it is grouped by.

Running a simple example like the one below will sort the grid based on the field specified in GroupByField, although It's not supposed to:
<radG:RadGrid runat="server" ID="rgrdtest" AutoGenerateColumns="true">
    <MasterTableView DataKeyNames="HierarchyId"  >
                        <GroupByExpressions >
               
                        <radG:GridGroupByExpression >
                            <SelectFields  >
                            <radG:GridGroupByField  FieldAlias="Title" FieldName="Title" FormatString=""  />
                            </SelectFields>
                            <GroupByFields>
                                 <radG:GridGroupByField  FieldName="HierarchyId" FieldAlias="HierarchyId" FormatString="" />
                            </GroupByFields>
                        </radG:GridGroupByExpression>
                   
                    </GroupByExpressions> 
    </MasterTableView>
</radG:RadGrid>

Is there a way to avoid that sorting so I can use the actual collection sort order ?

Thanks,
Andrei

7 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 17 May 2008, 10:15 AM
Hi Andrei,

You can control the sort order applied for the grouped fields through the GridGroupByField part of the GroupByFields collection of the group expression. Setting the SortOrder attribute of this GridGroupByField to None should do the trick:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/GroupBy/OutlookStyle/DefaultCS.aspx (see how this property is used from the aspx definition of the grid)

Additionally, to insert additional sort expressions if needed, consider adding sort expression programmatically to the SortExpressions collection of RadGrid for ASP.NET AJAX. For further details please review this online example of the product:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/Sort/DefaultCS.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Axel
Top achievements
Rank 1
answered on 13 May 2013, 09:27 PM
Hi Sebastian,
Im having the same issue, ive done what you suggested but it didnt work for me.
Im creating the groups programmaticlly, some like this:

  GridGroupByExpression expression = new GridGroupByExpression();
                GridGroupByField gridGroupByField = new GridGroupByField();

                gridGroupByField = new GridGroupByField();
                gridGroupByField.FieldName = "ESTACION";
                gridGroupByField.HeaderText = "ESTACION";
                gridGroupByField.HeaderValueSeparator = ": ";
                gridGroupByField.FormatString = "{0}";                
                expression.SelectFields.Add(gridGroupByField);

                gridGroupByField.SortOrder = GridSortOrder.None;
                expression.GroupByFields.Add(gridGroupByField);

                gtv.GroupByExpressions.Add(expression);

Thanks for your help.
0
Angel Petrov
Telerik team
answered on 16 May 2013, 01:36 PM
Hi Axel,

Following your scenario I have created a sample project to test whether I can replicate the problem but was unable to do so. Could you please review the attached solution and tell us what differs in your case? Additionally note that the last post in the forum thread is five years old and probably the issue has been resolved.

Kind regards,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Axel
Top achievements
Rank 1
answered on 17 May 2013, 05:45 PM
Hi Petrov,
This is a really good approach, now to replicate my case, you need to add this:
  • Every customer has a column that shows the total amount of all orders he has made.
  • Every group (Contact title) has a group total from all customers orders amounts that he groups.
  • The groups are ordered by the group total value descending. 
  • The group total is only visible on the group footer.


The data comes ordered from the query as I want, so I set the GridSortOrder to None, but it doesn't works :/ . I get the data ordered by "Contact title" A-Z .

Thanks for your help,
Axel
0
Angel Petrov
Telerik team
answered on 22 May 2013, 05:55 PM
Hello Axel,

I am sorry to say but ordering the values according to the footer aggregates is currently not supported by RadGrid. For now you can only sort by the value used for grouping in the particular case Contact Title.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Axel
Top achievements
Rank 1
answered on 22 May 2013, 07:53 PM
Hi Petrov,
Thanks for your reply. I already knew that was not possible, if you see on my previos post (Posted on May 13, 2013) I want to set the GridSortOrder to none with the previous conditions but it had no effect. I dont need to reorder the data because it comes ordered from the query, I just want to nullify the default sorting of the GridGroupByField object.  

I would appreciate your help.
Thanks.
Axel.


0
Angel Petrov
Telerik team
answered on 27 May 2013, 12:24 PM
Hi Axel,

Thank you for clarifying. I am afraid that the requirement can not be met. In order for the grouping to work correctly a sort order for the GridGroupByField is internally set(the default is ascending).

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Andrei
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Axel
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or