jQuery get data when using Ajax sourced
jQuery get data when using Ajax sourced
Hi,
I would like to modify cells that get sourced from Ajax in Datatables, had assumed something similar to:
var data = tableName.rows().data();
data.each(function (value, index) {
console.log(1); // Just to check it is actually working. It does for columns, but not rows
});
would work, but does not seem to be the case. Is there an alternative?
The reason I would like to do this is to modify the cells depending on a value of a user input. (Basically multiplication, which will require some html changes too)
I feel that the only alternative to this would be to not use ajax sourced data, but this seems incorrect?
If anyone has any suggestions, please let me know
- Thank you!
This question has an accepted answers - jump to answer
Answers
Look at the callbacks, you have a few options:
https://datatables.net/reference/option/createdRow
or
https://datatables.net/reference/option/preDrawCallback
You should be able to modify cell data in either of those functions, I'd probably use the createdRow in your case.
Thank you! Had a quick play around createdRow and it seems to have done the trick.
Thanks a lot for getting back to me