Can I get a DataSourceRequest from a KendoUI DataSource?

When a DataSource object (belonging to the Kendo UI framework) reads data from a server, it sends parameters to a structure, often called a Server-side DataSourceRequest (although there is not such a class officially). I am looking for a way to get this object from a DataSource because I want to send it somewhere without actually reading in the DataSource (and the Grid that uses it). Is it possible? I found this topic on the telelrik forum: http://www.telerik.com/forums/passing-current-datasourcerequest-to-a-custom-command , but the proposed solution is not suitable for me.

I would be grateful for any advice :)

+4
source share
3 answers

EdsonF's answer was right, but this approach is slightly better:

var data = grid.dataSource._params();
var prepared = grid.dataSource.transport.parameterMap(data);
location.href = "/MyController/MyDataEndPint?"+prepared;      

taken from here

+6
source

You can do it as follows:

Note: this is not an Ajax way - if you need an 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;
    }

Some time has passed since the question was asked, but I hope it helps others.

Hi

Edson

+3
source

. Kendo.Mvc.UI. , aspnetmvc.min.js, MVC.

0

Source: https://habr.com/ru/post/1530256/


All Articles