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

Order by groupby headers

2 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 20 Oct 2008, 01:49 PM
Hi,

Im trying to work out how to order by the group header.  I have the following grouping:

            GridGroupByExpression expression = new GridGroupByExpression(); 
            GridGroupByField gridGroupByField = new GridGroupByField(); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerName"
            gridGroupByField.HeaderText = "Customer Name"
            expression.SelectFields.Add(gridGroupByField); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerName"
            gridGroupByField.HeaderText = "Customer Name"
            expression.GroupByFields.Add(gridGroupByField); 
 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerStatus"
            gridGroupByField.HeaderText = "Customer Status"
            expression.SelectFields.Add(gridGroupByField); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerStatus"
            gridGroupByField.HeaderText = "Customer Status"
            expression.GroupByFields.Add(gridGroupByField); 
 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustStatusID"
            gridGroupByField.HeaderText = "Number of splits: "
            gridGroupByField.HeaderValueSeparator = " "
            // gridGroupByField.FormatString = "<strong style='color:red'>{0}</strong>"; 
            gridGroupByField.Aggregate = GridAggregateFunction.Count; 
            expression.SelectFields.Add(gridGroupByField); 
 
            rg_Results.MasterTableView.GroupByExpressions.Add(expression); 

I want to order by the customer status in the header, how would i do this?



2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Oct 2008, 07:48 AM
Hi,

You   can set the sort order of the group column accordingly as shown below. In this example I sort the group using the CustomerID field a shown below:

CS:
 protected void Page_Load(object sender, EventArgs e) 
        { 
            GridGroupByExpression expression = new GridGroupByExpression(); 
            GridGroupByField gridGroupByField = new GridGroupByField(); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CompanyName"
            gridGroupByField.HeaderText = "Company Name"
 
            expression.SelectFields.Add(gridGroupByField); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerID"
            gridGroupByField.HeaderText = "Customer ID"
      
            expression.SelectFields.Add(gridGroupByField); 
            gridGroupByField = new GridGroupByField(); 
            gridGroupByField.FieldName = "CustomerID"
            gridGroupByField.SortOrder = GridSortOrder.Descending; 
            expression.GroupByFields.Add(gridGroupByField); 
            RadGrid1.MasterTableView.GroupByExpressions.Add(expression); 
             
  
        } 


Thanks,
Shinu
0
Paul
Top achievements
Rank 1
answered on 21 Oct 2008, 09:30 AM
Thanks.  I had tried this but didnt realise the sort field had to be first in the list

Works a treat now
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Share this question
or