Inline Editing for certain fields only
Inline Editing for certain fields only
I have a table with inline editing. I can edit the field ok, but to save each change, i have to click off the datatable. If I select the datatable, I get a error:
uncaught exception: Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11
I assume the issue is that only certain fields can be edited onclick. BUt my onlick code is this:
$('#myTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
editorSignIn.inline( this, {
onBlur: 'submit'
} );
} );
How can I change it so only certain fields are onClick
thanks
This question has an accepted answers - jump to answer
Answers
If you just want to stop specific columns being inline edited, you would modify the selector on the
click
to be more selective. Currently you havetbody td:not(:first-child)
, but this can be more (or less) restrictive.If you want to base it on the contents of a cell, you can do something like this. That's for bubble editing, but the same applies for inline.
Colin
thanks Colin, how do I go about the first one? Being more restrictive.
It depends on how you want to restrict the jQuery selector. What is it you want to do?
Colin
I have a datatable with 5 fields, but I only want 3 of them to be editable.
That part is working, but when I click on one of the non-editable fields I get the console error above.
Did you make any changes to try being more restrictive?
You can use something like
:nth-child(3)
to keep from invoking the inline edit event handler for column 3. For example:http://live.datatables.net/hayojeci/1/edit
The example removes the first column and third column from the selectors for inline editing. It uses:
Kevin
perfect, thanks