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

[Solved] Groups order

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Edvard Pitka
Top achievements
Rank 1
Edvard Pitka asked on 02 Jul 2009, 09:12 PM

Is it possible to control the order of the groups on the grid, or disable grid's ordering mechanism and just display it in the order data is fed to the grid. Unfortunatelly, domain entities are fed directly to the UI and they do not have any meaningful attribute upon which to set the group expression. Here is how the data is being fed to the grid, and I would like the grid not to change the order.

   this.BaseProductBenefitsGrid.DataSource = Benefits  
                   .OrderBy(b => 
                   {  
                       switch (b.BenefitServiceGroup)  
                       {  
                           case "Inpatient":  
                               return 1;  
                           case "Outpatient":  
                               return 2;  
                           case "Other":  
                               return 3;  
                       }  
                       return 4;  
                   }).ThenBy(b => b.Type.DisplayOrderNumber).ToList();  
 
                BaseProductBenefitsGrid.DataBind(); 


and here is the group expression

    <GroupByExpressions> 
                        <telerik:GridGroupByExpression > 
                            <SelectFields > 
                                <telerik:GridGroupByField HeaderText="-" FieldName="BenefitServiceGroup"  HeaderValueSeparator="&nbsp;" SortOrder="None" /> 
                            </SelectFields> 
                            <GroupByFields> 
                                <telerik:GridGroupByField FieldName="BenefitServiceGroup" /> 
                            </GroupByFields> 
                        </telerik:GridGroupByExpression> 
                    </GroupByExpressions> 

so I would think that it should be possible to have groups ordered as Inpatient, Outpatient, Other. But grid reverses it and displays it as Inpatient, Other, Outpatient.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jul 2009, 05:52 AM
Hello Edvard,

Take a look at the following forum link that I found, which discusses on a similar issue. Hope this provides you with the required information:
GroupBy Sorting

Thanks
Princy.
Tags
Grid
Asked by
Edvard Pitka
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or