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

[Solved] change sort to click on column not just text?

3 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon-Jon Kershaw
Top achievements
Rank 2
Jon-Jon Kershaw asked on 07 May 2009, 07:38 PM
Sort only seems to work if you click on the text.  Is there any way to sort if you click anywhere in the column header?

Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 08 May 2009, 04:21 AM
Hi Jon,

Try the following code snippet to achieve the desired scenario.

CS:
 
protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)  
        {  
            foreach (GridHeaderItem header in RadGrid1.MasterTableView.GetItems(GridItemType.Header))  
            {  
                header[col.UniqueName].Attributes.Add("OnClick""return SortColumn('"+ col.UniqueName+ "');");  
            }  
        }  
   }  


JS:
 
 
<script type="text/javascript">  
        function SortColumn(ColumnName)  
        {  
         var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();  
          masterTable.sort(ColumnName);  
        }  
        </script>  


Thanks
Shinu.

0
Jon-Jon Kershaw
Top achievements
Rank 2
answered on 08 May 2009, 04:12 PM
Thanks!  Thats a good one to keep in the bank for future reference.
0
H
Top achievements
Rank 1
answered on 23 Nov 2009, 07:46 AM
How can i prevent multiple postbacks?
In 2009 Q3 the are one postback for the title (text) and one for the columnclick.
Tags
Grid
Asked by
Jon-Jon Kershaw
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Jon-Jon Kershaw
Top achievements
Rank 2
H
Top achievements
Rank 1
Share this question
or