Is it possible to get the DataSourceRequest from KendoUI DataSource object?
Asked Answered
M

3

5

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

Maharaja answered 5/3, 2014 at 14:36 Comment(0)
N
8

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

Nava answered 5/9, 2014 at 15:32 Comment(0)
P
3

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

Perspicacious answered 27/8, 2014 at 14:37 Comment(0)
A
0

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.

Arbitress answered 5/3, 2014 at 18:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.