export class Selectioning extends SampleBase {
toolbarOptions = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true };
index = 0; //index
flag = true;
isUpdated = true; //flag variable
selectedIndex = 0;
rowDeselected(args) {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
if (grid && args.data[0].Read === false)
{
this.index = args.rowIndex[0];
var newRecord = {...args.data[0], Read: true }
this.flag = true;
var selrow = this.index + 1
if (this.isUpdated) {
this.isUpdated = false;
grid.selectRow(selrow);
grid.updateRow(args.rowIndex[0], newRecord);
}
}
}
actionComplete(args) {
if(args.requestType === "refresh") {
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
grid.selectRow(this.index); //select the row based on the index
this.isUpdated = true;
}
}
render() {
return (<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={this.datas} toolbar={this.toolbarOptions} editSettings={this.editSettings} rowDeselected={this.rowDeselected.bind(this)} actionComplete={this.actionComplete.bind(this)} allowPaging={true} selectionSettings={this.settings} pageSettings={{ pageCount: 5 }} selectionSettings={{ type: 'Multiple' }}>
<ColumnsDirective>
. . . . . . .
. . . . . . .
</ColumnsDirective>
<Inject services={[Page, Selection, Toolbar, Edit]}/>
</GridComponent>
</div>
</div>);
}
}
|