Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 739
Rummy Avatar asked Jan 11 '23 02:01

Rummy


2 Answers

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

like image 73
Mahmood Dehghan Avatar answered May 01 '23 14:05

Mahmood Dehghan


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

like image 40
EdsonF Avatar answered May 01 '23 15:05

EdsonF