Can I get the editor to automatically select a newly added row in the table?
Can I get the editor to automatically select a newly added row in the table?
tchristfort
Posts: 22Questions: 7Answers: 0
in General
I tried the postSubmit event, but at this time the new row is not added to the table so the last row is just before the newly inserted. Is there an event called when a new row is added to a table I could use?
This discussion has been closed.
Answers
The best bet would be to use
postCreate
at this point, as the row would have been added to the table by that point. See example here,Colin
Thanks Colin,
I tried to add the postCreate trigger. The trigger fired correctly, however the console.log statement said 'undefined' to the id paramter. I'm using DataTables-1.10.16
Any idea what is wrong?
Its hard to say what the problem might be without seeing it. At minimum you can post your code here. Better is a link to your page or a test case replicating the issue so we can see what you have.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
You can use the browser's debugger to evaluate the statement to find out what is actually is actually
undefined
.Kevin
It is difficult to create a test case as closely integrated with server side mysql processing. I have added this code:
editor.on('postCreate', function(e, json, data, id) {
console.log(id);
table.row('#'+id).select();
});
If I console.log e, json and data these are definded, however id is not defined in the function.
According to the
postCreate
docs:What version of Editor do you have?
Your code works in this example:
http://live.datatables.net/guwafemu/125/edit
Kevin
Sorry for late reply, my data tables is 1.10.16, but now see that the Editor folder say: Editor-PHP-1.7.2 so that may be the problem.
Do I need to update both DataTables and Editor?
It would be best to keep them in sync, so yep, best to update both,
Colin