Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144046 | Apr 16,2019 06:19 AM UTC | Apr 24,2019 10:58 AM UTC | JavaScript - EJ 2 | 7 |
![]() |
Tags: Grid |
[index.js]
ej.base.enableRipple(true);
var grid = new ej.grids.Grid({
dataSource: window.orderDataSource,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition:'Top' },
allowPaging: true,
allowSelection: true,
selectionSettings: { type: 'Multiple' },
pageSettings: { pageCount: 5 },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
toolbarClick: toolbarClick,
columns: [
{
field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID', textAlign: 'Right',
validationRules: { required: true, number: true }, width: 140
},
----
],
});
grid.appendTo('#Grid');
function toolbarClick(args){
if(args.item.text == "Delete"){
args.cancel = true; // To prevent the further action done by toolbarclick event
var selectedRows = grid.getSelectedRecords().filter(it => it.ShipCountry == "France" || it.ShipCountry == "Belgium" || it.ShipCountry == "Brazil");
selectedRows.forEach((element) => {
grid.deleteRecord("OrderID", element);
console.log(element);
});
}
}
|
function toolbarClick(args){
if(args['item']["properties"].id == "Grid_delete_custom"){
args.cancel = true;
. . . .
});
}
} |
var selectedRows = grid.getSelectedRecords().filter(it => it.status == 0 || it.status == 1 || it.status == 2); |
function toolbarClick(args) {
if (args['item']["properties"].id == "Grid_delete") {
args.cancel = true;
var gridObj = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
var selectedRowIndexes = grid.getSelectedRowIndexes(); // Get seleted rows index
grid.clearSelection();
var RowsIndex = [];
for (var i = 0; i < selectedRowIndexes.length; i++) {
var rowObj = grid.getRowsObject()[selectedRowIndexes[i]]; // Get the selected row object based on the selected index
if (rowObj.data.CustomerID == null || rowObj.data.CustomerID == "VINET" || rowObj.data.CustomerID == "HANAR" || rowObj.data.CustomerID == "TOMSP") { // Applied the filter for each rows
RowsIndex.push(selectedRowIndexes[i]); // Stored the rows index if its getting filtered
}
}
grid.selectRows(RowsIndex); // Select all filtered rows based on the stored index
grid.deleteRecord() // Delete the total selected records
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.