|
this.array = [];
actionComplete(args) {
var gridObj = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
for(var i =0 ; i< this.array.length; i++) {
var cell = gridObj.getCellFromIndex(parseInt(this.array[i].split('of')[1]) , parseInt(this.array[i].split('of')[0]));
cell.classList.add('e-modified');
}
}
cellSaved(args) {
this.array.push(parseInt(args.cell.getAttribute('aria-colindex')) + 'of' + parseInt(args.cell.getAttribute('index')))
}
.e-modified {
background: lawngreen;
} |
To determine the unsaved changes in batch editing mode you can use the ‘getBatchChanges’ method which returns an object that includes arrays of addedRecords, changedRecords and deletedRecords. If there is no unsaved changes this method returns empty arrays.
|
export class BatchEdit extends SampleBase {
constructor() {
super(...arguments);
this.toolbarOptions = ['Add', 'Delete', 'Update', 'Cancel'];
this.editSettings = {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: 'Batch'
};
this.editparams = { params: { popupHeight: '300px' } };
this.validationRule = { required: true };
this.orderidRules = { required: true, number: true };
this.pageSettings = { pageCount: 5 };
this.handleKeyDown = this.handleKeyDown.bind(this);
this.functionA = this.functionA.bind(this);
this.functionB = this.functionB.bind(this);
}
functionA() {
console.log('Function A Called');
}
functionB() {
console.log('Function B Called');
}
handleKeyDown(args) {
if (!this.gridInstance.isEdit) {
if (args.key == 'a') {
this.functionA();
} else if (args.key == 'b') {
this.functionB();
}
}
}
render() {
return (
<div className= "control-pane" onKeyPress = { this.handleKeyDown } >
<div className="control-section" >
<div className="col-md-9" >
<GridComponent
ref={ grid => (this.gridInstance = grid) }
dataSource = { data }
pageSettings = { this.pageSettings }
toolbar = { this.toolbarOptions }
allowPaging = { true}
editSettings = { this.editSettings }
>
<ColumnsDirective>
<ColumnDirective
field="OrderID"
headerText = "Order ID"
width = "120"
textAlign = "Right"
validationRules = { this.orderidRules }
isPrimaryKey = { true}
/>
<ColumnDirective
field="CustomerName"
headerText = "Customer Name"
width = "150"
validationRules = { this.validationRule }
/>
<ColumnDirective
field="Freight"
headerText = "Freight"
width = "120"
format = "C2"
textAlign = "Right"
editType = "numericedit"
/>
<ColumnDirective
field="OrderDate"
headerText = "Order Date"
editType = "datepickeredit"
format = "yMd"
width = "170"
/>
<ColumnDirective
field="ShipCountry"
headerText = "Ship Country"
width = "150"
editType = "dropdownedit"
edit = { this.editparams }
/>
</ColumnsDirective>
< Inject services = { [Page, Toolbar, Edit]} />
</GridComponent>
< /div>
< /div>
< /div>
);
}
}
render(<BatchEdit />, document.getElementById('sample'));
|