fnRowCallback when one field is edited make one cell read only/ non-editable
fnRowCallback when one field is edited make one cell read only/ non-editable
Running Datatable Editor v1.9.4
I'm trying to disable a cell from being editable once the completed column has been set to 1. I figured changing the desired cell to "Read only" might work, but it did not.
I have this code:
fnRowCallback: function( nRow, aData, iDisplayIndex ) {
var completedField = aData['completed'];
if(completedField == 1){
$('td:eq(14)', nRow).addClass("read_only");
}
return nRow;
}
Which will make a "Note" column read only if the completed field is marked as 1. When I inspect a row with a completed field = 1, it does show in the browser elements that this specific cell has a "class = read_only", however, I'm still able to edit this cell via edit button or by AutoFill/Keys. Is there a way to do this?
This question has an accepted answers - jump to answer
Answers
This example from this thread should help. It's disabling a field - the logic is different to what you want, but it should set you off in the right direction,
Colin
@colin I almost got it to work. The only problem is that it disables all of the rows. Here is my current code,
How can I make it look at each row to disable?
Nvm I found out what it was:
@colin I'm running an issue where AutoFill/Keys isn't allowing me to change the completed field. Not sure why. It works just fine when I hit the "edit" button and change a completed field from 1 to 0 or vice versa.
Is that the same issue you reported on that other thread?
Colin
@colin I think they are related
@colin, if remove the
I'm able to make changes to the editable fields via the Autofill/Key with no issues.