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

Pass DataSourceRequest as Parameter in Javascript Ajax Call

2 Answers 667 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jillian
Top achievements
Rank 1
Jillian asked on 06 May 2014, 03:53 PM

I have a page that has a grid and some filter fields (external from the grid).  The filtering gets applied to the grid in the JavaScript - which works fine.  I also have an export button that I need to export the data in my grid - since my grid does not contain all the data that my export needs, my thought was to pass the DataSourceRequest as a parameter to my Ajax call, select my data and then use the "toDataSourceResult()" as happens in my ajax read controller action. This is not working. 

I have the following code in my javascript function that builds my datasource request, and passes it in as a parameter, but my DataSourceRequest object in my controller action contains null values for filter, sort, etc.

var grid = ${"#Persons").data("kendoGrid");
var parameterMap = grid.dataSource.transport.parameterMap;
var requestObject = parameterMap({ Sorts: grid.dataSource.sort(), Filters: grid.dataSource.filter(), Groups: grid.dataSource.group()});

How can I pass the datasource request as a parameter to my Ajax Controller action? I have attached a working sample project.

2 Answers, 1 is accepted

Sort by
0
Jillian
Top achievements
Rank 1
answered on 07 May 2014, 01:01 PM
I resolved this by changing

var requestObject = parameterMap({ Sorts: grid.dataSource.sort(), Filters: grid.dataSource.filter(), Groups: grid.dataSource.group()});

to

var requestObject = parameterMap({ sort: grid.dataSource.sort(), filter: grid.dataSource.filter(), group: grid.dataSource.group()});

and adding my additional parameters I wanted to pass into the ajax controller action to my requestObject, instead of including them in the "data" setting of my javscript ajax call.
0
EdsonF
Top achievements
Rank 2
answered on 27 Aug 2014, 12:07 PM
Hi Jillian

I'm have exactly the same problem as you and although I change you sample project to what you mentioned on the second post, it still does not work - see attached.

Can you help me find out what I'm doing wrong ?

Thanks in advance

Edson
Tags
Grid
Asked by
Jillian
Top achievements
Rank 1
Answers by
Jillian
Top achievements
Rank 1
EdsonF
Top achievements
Rank 2
Share this question
or