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

how to get grid orderby value?

6 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeremy
Top achievements
Rank 1
Jeremy asked on 01 Feb 2011, 02:43 PM
Hi,

I want to get grid orderby value in my ASP NET MVC application when I click on column header.
Can anyone help me around this?

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Feb 2011, 03:00 PM
Hello Jeremy ,

 You can use the internal "orderBy" field of the grid client-side object. However make sure your code is executed after it has been updated.

 Can you tell us what are you trying to achieve? There could be an easier way to do the same without the need of using internal fields. 

Regards,
Atanas Korchev
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
Jeremy
Top achievements
Rank 1
answered on 02 Feb 2011, 09:07 AM
I just want to save the orderby field value when we click on the grid in order to sort.
And get the sorted data everytime I visit the page and export the same. However I am visiting the entire application.
Everytime I should get the sorted data.
0
Atanas Korchev
Telerik team
answered on 02 Feb 2011, 09:09 AM
Hi Jeremy ,

 You can use the OnDataBinding JavaScript event of the grid if you are using ajax binding. From there extract the orderBy field of the grid and store it for future use. If you want to do this on the server side - add a string parameter called orderBy to your action method.

Regards,
Atanas Korchev
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
Jeremy
Top achievements
Rank 1
answered on 02 Feb 2011, 09:38 AM

Thanks for the quick response.

I did the same you explained but how can I pass the stored value to the action from javascript. I am using ajax databinding and already passing parameters to the action on the binding.

see below:

 

.DataBinding(dataBinding => dataBinding.Ajax()

.Select(

 

"_ajaxdatabinding", "controller", new

 

 

 

 

{

 

Id = (as Id

 

)ViewData["id"]).id

 

}))

now I need to pass the stored orderby value to the same action method through javascript.

0
Jeremy
Top achievements
Rank 1
answered on 02 Feb 2011, 09:53 AM
java script function :

 

 

function onDataBinding() {

 

 

 

var grid = $("#grid").data("tGrid");

 

 

 

 grid.orderBy;

 

}

0
Atanas Korchev
Telerik team
answered on 02 Feb 2011, 11:11 AM
Hi Jeremy ,

 In this case just add a parameter to your action method:

public ActionResult _ajaxdatabinding(int Id, string orderBy
{
}

Regards,
Atanas Korchev
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
Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or