Reputation: 344
I have a grid that contains a list of Id's with a button which contains state (Boolean Y/N) , I am calling a function at the click of a button to get all N Id's which is loading data from the grid.
function getAll(){
var page = $("#grid").data("kendoGrid").dataSource.page();
console.log(page);
var onlyFailedIds = $('#grid').data("kendoGrid").dataSource.read().then(function(){console.log(dataSource.view()[0].items.filter(row=>row.status==='N').map(row=>row.Id) )});
}
The problem is that I am always getting results of page 1 even when I change the page of grid. How do I get results from other pages?
Upvotes: 0
Views: 747
Reputation: 6131
You are using DataSource's view method. According to the documentation:
Returns the data items which correspond to the current page, filter, sort, and group configuration.
You should be using the DataSource's data method. According to the documentation:
Gets or sets the data items of the data source.
For example:
const grid = $('#grid');
if (!grid) { return; }
const gridKendoGrid = grid.data('kendoGrid');
if (!gridKendoGrid) { return; }
const dataSource = gridKendoGrid.dataSource;
if (!dataSource) { return; }
dataSource.read().then(() => {
const data = dataSource.data();
if (!data) { return; }
const failedIds = data
.filter(row => row.status === 'N')
.map(row => row.Id);
console.log(failedIds);
});
Upvotes: 1