0
votes

There is out of the box support for exporting Kendo Grid data in Xlsx and Pdf formats, I'm looking for something similar for exporting in Csv format.

I have tried the server export described in: https://demos.telerik.com/aspnet-mvc/grid/server-export, which just sends the visible rows to the action; My unfiltered grid has over 250k entries. The output I'm looking for is the data in this table with the filters applied. I can get the data again in the same way the grid was populated and filter the data server-side, but how do we pass the selected filters to the action?

There appears to be a number of possible solutions, but I'm hoping to save time on going down a dead end. The documentation is often good with Kendo, but I'm struggling to find what I need with this one.

1
Sorry, I misread your post and posted/deleted wrong answerthmshd

1 Answers

0
votes

A possible solution is to get the filters applied on the Grid and send it to the server side and export the result as a expected format. To get the filter applied on the grid, you have to act over the dataSource.

var grid = $("#myGrid").data("kendoGrid");
var filter = grid.dataSource.filter();

Then, you have to send via jquery ajax, the filter.filters array to an action and bind it into a Type, maybe, something like this:

public class GridData
{
    public GridFilter[] Filters { get; set; }
    public string Logic { get; set; }
}

public class GridFilter
{
    public string Operator { get; set; }
    public string Field { get; set; }
    public string Value { get; set; }
}

Then, get the data based on the GridData object and return provide the CSV information.