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

button to show current sort order

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve LaForge
Top achievements
Rank 1
Steve LaForge asked on 12 Aug 2010, 10:06 PM
I have a grid with multicolumn sorting enabled.  The user needs to be able to see what the currently selected sort order is.  I've created a button and attached the following javascript to execute via the onclientclick event.

It identifies the grid and the mastertableview with no trouble, but nothing is returned by the get_sortExpressions(), so the resulting message is empty.

What am I missing?

Thanks!

    function showSortOrder() {
      var grid = $find("<%=gridResults.ClientID %>")
      alert("Grid = " + grid);
      var mstrvw = grid.get_masterTableView();
      alert("mstrvw = " + mstrvw);
      var sortExpressions = grid.get_masterTableView().get_sortExpressions();
      alert("sortExpressions = " + sortExpressions);
      // alert("sortExpressions length = " + sortExpressions.length);
        
      var msg = "The current sort order is\n";
//      for (i = 0; i < sortExpressions.length; i++)
//        {
//          var expression = sortExpressions[i];
//          var fieldName = expression.get_fieldName();
//          var sortOrder = expression.get_sortOrder();
//          msg = msg + fieldName + " (" + sortOrder + ")\n"
//        }
      //      alert(msg);
      alert(msg + sortExpressions.toString());
    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 18 Aug 2010, 10:08 AM
Hello Steve,

The get_sortExpressions() method along with get_filterExpressions() are meaningful only when you use client-side binding for your RadGrid control. Otherwise, as sorting is done on the server, the sort expressions are not kept on the client. In this case you can take the sort expressions and sort order server-side and depending on your needs you can for example keep them in asp HiddenField controls in order to show them on the client.

Sincerely yours,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Steve LaForge
Top achievements
Rank 1
answered on 18 Aug 2010, 11:53 PM
Thanks!  Your suggestion definitely led me down the right path.
Tags
Grid
Asked by
Steve LaForge
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Steve LaForge
Top achievements
Rank 1
Share this question
or