Hello everyone,
I'm trying to create a function for validation of a select columns to prevent the user from selecting options that have already been selected in other rows. I've managed to get it to work for new rows using getData. But if I edit a row and don't change it this doesn't work as the getData returns the values of all rows (including the one I'm editing) and as so detects the value is already being used and won't save.
Is there a way to get the data from all the rows except the one I'm editing? Or get number of the row I'm editing so I can exclude it from the array that getData returns?
I'll leave my code below so you can take a look.
Thanks in advance.
validations: [
{ type: function (ui) {
var value = ui.value;
var values = $grid.pqGrid("getData", { dataIndx: [ui.column.dataIndx] } );
for (i = 0; i < values.length; i++) {
if(values[i][ui.column.dataIndx] == value) {
ui.msg = "Duplicate entry";
return false;
}
}
}
}
]