When DataSource object (belonging to Kendo UI framework) reads data from server it sends parameters in a structure that is often called DataSourceRequest on server side (although officialy there is no such class). I am looking for a way to get this object from DataSource because I want to send it somewhere without performing actual read on the DataSource (and the Grid that uses it). Is it possible? I found this thread on telelrik forum: http://www.telerik.com/forums/passing-current-datasourcerequest-to-a-custom-command but suggested solution is no good for me.
I will be grateful for any tips :)
EdsonF's answer was right but this approach is a little better:
var data = grid.dataSource._params();
var prepared = grid.dataSource.transport.parameterMap(data);
location.href = "/MyController/MyDataEndPint?"+prepared;
taken from here
You can do it the following way:
Note: this is not the Ajax way - if you need the Ajax way let me know
ExportData = function () {
var grid = $("#myGrid").data("kendoGrid");
var parameterMap = grid.dataSource.transport.parameterMap;
var sortData = grid.dataSource.sort();
var filterData = grid.dataSource.filter();
var groupData = grid.dataSource.group();
var data = parameterMap({ sort: sortData, filter: filterData, group: groupData });
var request = decodeURIComponent($.param(data));
location.href = "/MyController/MyDataEndPint?"+request;
return false;
}
Its has been a while since the question was asked but hopefully it will help others.
Regards
Edson
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With