Question

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 :)

Was it helpful?

Solution

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

OTHER TIPS

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

There is such class. You just need to add the using Kendo.Mvc.UI. And it is send to the server in that specific format if you have added the aspnetmvc.min.js file and you are using the MVC wrappers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top