var grid = new ej.grids.Grid({
dataSource: window.orderDataSource,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal'},
allowPaging: true,
pageSettings: { pageCount: 5 },
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
actionBegin: actionBegin,
columns: [
{
field: 'OrderID', isPrimaryKey: true, headerText: 'Order ID' validationRules: { required: true, number: true }, width: 140
},
{
field: 'CustomerID', headerText: 'Customer ID',
validationRules: { required: true }, width: 140
},
{
field: 'ShipCountry', headerText: 'Ship Country', editType: 'dropdownedit', width: 150,
edit: { params: { popupHeight: '300px' } }
}
],
});
grid.appendTo('#Grid');
function actionBegin(args) {
if (args.requestType === 'beginEdit') {
if(args.rowData.CustomerID.includes("V")){
// enable and disable editing for shipCountry column
this.columns[2].allowEditing = true;
} else {
this.columns[2].allowEditing = false;
}
}
}
|