Hi there,
I have a grid with an excel export. I'm filtering the data source of the grid in javascript via some drop down lists. The filtering is done via the server. To be clear the when the grid's data source has been instructed to read it scrapes values from the filters using the .data() method and sends the filters values with the read request.
When I export to excel I noticed that it always returns the initial amount of data bound to the grid i.e. I have three rows when the page loads, I filter down to one row then export to excel and it returns all three rows. I noticed that when the export was happening it seemed to be exporting whatever was in the datasource options.data. I've found a workaround which is
var settings = {};
$(me.selectors.excelExport).on('click', function() {
var $this = $(this),
$grid = $this.closest(me.selectors.role),
grid = $grid.data(me.name);
if (grid) {
settings = grid.dataSource.options.data;
grid.dataSource.options.data = grid.dataSource.view();
}
});
on clicking export to excel i change the grid's datasource.options.data to be the current "view" of data and i store the original data.options.data.
var grid = $(me.selectors.role).data(me.name);
if (grid) {
grid.bind(me.events.excelExport, function(e) {
grid.dataSource.options.data = settings;
});
}
then after the export has finished I then restore the datasource.options.data with the value i stored before.
Should I need to do this or am I misunderstanding something?
Please let me know if you need additional information or if I've not been clear enough.
Thanks
Tom