Editor - Selecting a row using inline editing
Editor - Selecting a row using inline editing
Hi
Is it possible to select a row at the same time as clicking on an inline cell?
At the moment if I click on a non-enterable cell, then the row gets selected.
Clicking on an enterable cell goes into edit mode, but does not select the row. However, if I click that cell a second time it does select the row but then I get an error:
_Uncaught Unable to automatically determine field from source. Please specify the field name. For more information, please refer to https://datatables.net/tn/11
_
I thought about putting a listener on focusin - tr, but it does not seem to make any difference:
The setup of the table is very simple (add the class enterable to the cells I want to edit) and I have setup the keys and select:
keys: {
columns: ".editable",
keys: [9],
editor: receiptEditor,
editOnFocus: true,
blurable: true
},
select: {
select: true,
style: "single",
selector: "td",
blurable: false
},
I then created an event for enterable fields:
$("#receiptTable").on("click", "td.editable", function () {
receiptEditor.inline();
});
Thanks for your help.
Dov
This question has an accepted answers - jump to answer
Answers
I think I have answered my own question.
I added the following event listener and it seems to be working:
Is this the best way of achieving row selection and inline editing at the same time?
I still have one question about the error when clicking on a cell a second time. What could be causing this?
Hi @eurosoll ,
It should work fairly cleanly out of the box - see this example here. If that's not what you're after, would you be able to modify that example to show your configuration, please.
Cheers,
Colin
Hi Colin
Thanks for your reply.
I have amended the example to fit in exactly with mine.
http://live.datatables.net/nasuyuli/3/edit?html,css,js,output
I have narrowed the issue down to keytables. If I take it out, the select works as expected.
Would you know what is stopping the select working with that plugin?
Thanks
Dov
I'm reasonably certain that it will be this line of code that is stopping the row being selected. It stops the click event from bubbling up, so Select never sees it the first time around.
If allowing row select, I normally would suggest having a column of checkboxes since clicking on a cell to perform two actions (select + edit) is quite confusing. For example clicking on the input box after the first click would deselect the row.
Allan
Thanks for your help.