Programatically position the on-line editor on a cell.
Programatically position the on-line editor on a cell.
gastonceron
Posts: 4Questions: 2Answers: 0
in Editor
When using in-line editing, by clicking on a button I can programmatically focus on a particular cell, say row=1, column=2. If I click on that focused cell the editor comes up and I can start editing. I need to start editing without having to click on the cell.
This is my code:
$('#testButton').on("click", function () {
var row_selector = $('#example').DataTable().row(1);
var column_selector = $('#example').DataTable().column(2);
var home_cell = $('#example').DataTable().cell(row_selector, column_selector);
home_cell.focus(); // this works: it focuses on cell on row 1, column 2
editor.inline(home_cell); // this does not work, produces an error.
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I found that I can get what I want as follows, but it just seems too dirty to me:
Hi @gastonceron ,
You could just pass in the jQuery node, so row 1 column 2 would be:
see example here,
Cheers,
Colin
Thanks Colin, I like your solution better than mine. However both yours and mine will leave the cursor at the end of the text, like a click on the cell would. Is there any way to emulate a double click on the cell so that the whole text is selected?
This thread should help:
https://datatables.net/forums/discussion/comment/68559/#Comment_68559
Kevin