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

Multi Column Programmatic sorting on load of radgrid

2 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dheeraj
Top achievements
Rank 1
Dheeraj asked on 12 May 2010, 07:53 AM
hi,
      I have a requirement of multi column sorting like -  Default Sorting on Columns ,first "Priority", followed by "TargetDate" and then the "Status" on Load of Grid . Right now I am able to apply Sorting on Single column like -

GridSortExpression

 

expression = new GridSortExpression();

 

expression.FieldName =

"Status";

 

expression.SetSortOrder(

"Descending");

 

 

this.RadGrid1.MasterTableView.SortExpressions.AddSortExpression(expression);

 


But How to apply it on Multiple no of columns.Please any body suggest me regarding this.

Regards,
Dheeraj

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 May 2010, 11:25 AM
Hello Dheeru,

You need to create a GridSortExpression for every column that you want to sort and add to GridTableView's SortExpressions collection. Check out the following code

C#:
 
 protected void Page_Load(object sender, EventArgs e) 
    { 
 
        this.RadGrid1.MasterTableView.SortExpressions.Clear(); 
        GridSortExpression sortExpr1 = new GridSortExpression(); 
        sortExpr1.FieldName = "CustomerID"
        sortExpr1.SortOrder = GridSortOrder.Ascending; 
        this.RadGrid1.MasterTableView.SortExpressions.AddSortExpression(sortExpr1); 
 
        GridSortExpression sortExpr2 = new GridSortExpression(); 
        sortExpr2.FieldName = "EmployeeID"
        sortExpr2.SortOrder = GridSortOrder.Ascending; 
        this.RadGrid1.MasterTableView.SortExpressions.AddSortExpression(sortExpr2); 
   } 




Also do not forget to set AllowMultiColumnSorting as true.

Regards,
Shinu.

0
Dheeraj
Top achievements
Rank 1
answered on 13 May 2010, 06:03 AM
Thanks a lot Shinu.

Regards,
Dheeraj
Tags
Grid
Asked by
Dheeraj
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dheeraj
Top achievements
Rank 1
Share this question
or