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

Reset Sorting from clientside

3 Answers 264 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Toby
Top achievements
Rank 1
Toby asked on 23 Nov 2010, 01:52 PM
Is it possible? I have tried

from http://www.telerik.com/help/aspnet-ajax/grid_sort.html

var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
masterTable.sort("");

but it does not seem to do anything?

I need to do it from client side as when you click on different nodes in in my treeview it will rebinds the grid to different columns, so it needs to clear the column sort at the same time.

thanks
Toby

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 25 Nov 2010, 01:02 PM
Hi Toby,

You could not reset the sorting of the RadGrid on the client side. However you could achieve it on server side by clearing the RadGrid1.MasterTableView.SortExpressions collection, and rebinding the control. This will make sure no sort expressions are present. For example you could firing the grid command from client side:
var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
masterTable.fireCommand("CustomCommand");

Then on server side you could handle this command into the ItemCommand event:
void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "CustomCommand")
    {
        RadGrid1.MasterTableView.SortExpressions.Clear();
        RadGrid1.Rebind();
    }
}

Please give it try and let me know if it helps you.

Greetings,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Toby
Top achievements
Rank 1
answered on 25 Nov 2010, 01:44 PM
I have tried that but the server side method

RadGrid1_ItemCommand


does not get fired when calling it from javascript i.e.

masterTable.fireCommand("CustomCommand");

the server method does get called ok when performing sorting etc so the event is wired up correctly, Do I need to do anything else to enabled custom commands to be fired?

thanks
0
Radoslav
Telerik team
answered on 26 Nov 2010, 01:04 PM
Hi Toby,

I am sending you a simple example. Please check it out and let me know if it helps you.

All the best,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Toby
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Toby
Top achievements
Rank 1
Share this question
or