[index.html]
<ejs-button id="clickbutton" content="getFilteredData"></ejs-button>
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" allowPaging="true" allowFiltering="true">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer ID" width="100"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="Employee ID" width="100"></e-grid-column>
<e-grid-column field="Freight" width="100"></e-grid-column>
<e-grid-column field="Verified" headerText="Verified" width="100"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
document.getElementById('clickbutton').addEventListener('click', function (e) {
var f_data;
var grid = document.getElementById('Grid').ej2_instances[0];
var query = grid.renderModule.data.generateQuery(); // get grid corresponding query
for (var i = 0; i < query.queries.length; i++) {
if (query.queries[i].fn == 'onPage') {
query.queries.splice(i, 1); // remove page query to get all records
break;
}
}
var dm = new ej.data.DataManager(grid.dataSource)
f_data = dm.executeLocal(query);
alert(f_data.length);
}
);
</script>
|