Hello,
I have a grid with custom validation for unique value. Everything is OK for NEW data, but not OK for UPDATE data. This is because I can not put condition whether the data is change or not. And that is because I can not get the original value to be put to the custom validation function.
How to get original value, the value before editing, at custom validation function? So I can put logic measure whether the data is change or not.
note: the data is not change, but get trapped by custom validation.
Below the custom validation code :
args.form.ej2_instances[0].addRules('name', { |
Thank you in advance
Best regards,
Ismail
|
validationRules: {
required: true,
minLength: [
(e) => {
var prev = grid.getRowInfo(grid.getRowByIndex(index));
if (prev.rowData.CustomerID != e['value']) {
for (var i = 0; i < grid.dataSource.length; i++) {
if (e['value'] === grid.dataSource[i].CustomerID) {
return false;
}
}
return true;
}
else {
return true;
}
},
'Enter a unique value',
],
}, |
Hi Thiyagu,
Thank you for your update info and example. Your provided example is working and give me an idea. Because, I initialize the control at grid actionComplete, so I take advantage of args.rowData to take the original value and its work seamlessly.
Below my custom code for unique value validation that using args.rowData
args.form.ej2_instances[0].addRules('name', { |
Thank you also for the side note.