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

Multi Sort Limit..

2 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dip
Top achievements
Rank 1
Dip asked on 29 Jan 2009, 02:34 AM
I have a radgrid with 10 column which need multi sorting but I have to limit to three column.
Like,

ID   FIRST   LAST   TEL   EMAIL
1       2           3
But if he clicks 'TEL' now, then
ID   FIRST   LAST   TEL    EMAIL
         1           2         3
Anyone can help me out..If possible I need to switch images to indicate three column differently?


Thanks,
DIP

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 29 Jan 2009, 01:14 PM
Hi Dip,

 Give a try with the following code snippet and see whether it helps.

CS:
  protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        int sortCount = RadGrid1.MasterTableView.SortExpressions.Count; 
        if (sortCount > 0) 
        { 
            if (sortCount > 3) 
            { 
 
 
                string strUniqueName = RadGrid1.MasterTableView.SortExpressions[0].FieldName; 
 
                GridSortExpression sortExp = new GridSortExpression(); 
                sortExp.FieldName = strUniqueName; 
                RadGrid1.MasterTableView.SortExpressions.RemoveSortExpression(sortExp); 
            } 
            for (int i = 0; i <= sortCount - 1; i++) 
            { 
 
                if (i == 0) 
                { 
                    string strUniqueName1 = RadGrid1.MasterTableView.SortExpressions[i].FieldName; 
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName1).SortAscImageUrl = "Image1.gif"
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName1).SortDescImageUrl = "Image1.gif"
 
                } 
                else if (i == 1) 
                { 
                    string strUniqueName2 = RadGrid1.MasterTableView.SortExpressions[i].FieldName; 
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName2).SortAscImageUrl = "Image2.gif"
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName2).SortDescImageUrl = "Image2.gif"
                } 
                else if (i == 2) 
                { 
                    string strUniqueName3 = RadGrid1.MasterTableView.SortExpressions[i].FieldName; 
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName3).SortAscImageUrl = "Image3.gif"
                    RadGrid1.MasterTableView.GetColumnSafe(strUniqueName3).SortDescImageUrl = "Image3.gif"
                } 
            } 
           
            RadGrid1.MasterTableView.Rebind(); 
 
 
        } 
          
    } 


Thanks
Shinu
0
Dip
Top achievements
Rank 1
answered on 29 Jan 2009, 08:34 PM
Can't ask better then this...thanks a lot...
Tags
Grid
Asked by
Dip
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dip
Top achievements
Rank 1
Share this question
or