Loading data into a cell of a table via AJAX
Loading data into a cell of a table via AJAX
Tonyatdcu
Posts: 3Questions: 0Answers: 0
Guys,
I'm evaluating DataTables for a project I'm working on and have made excellent progress in the last day or so. I've loading large database tables into the DataTables object using AJAX and it's working beautifully.
However, one column of the table needs to come from another computed table lookup. So I need to load a cell with this data using an AJAX lookup. I tried doing this using the fnRender
"fnRender": function ( o, val ) {
jQuery.ajaxSetup ({ cache: false });
var row = $(this).closest('tr');
$(row).load('dt_getactivity.php');
}
but this doesn't work.
Can you guys shed some light on how to dynamically load this content?
Thanks in advance,
Tony
I'm evaluating DataTables for a project I'm working on and have made excellent progress in the last day or so. I've loading large database tables into the DataTables object using AJAX and it's working beautifully.
However, one column of the table needs to come from another computed table lookup. So I need to load a cell with this data using an AJAX lookup. I tried doing this using the fnRender
"fnRender": function ( o, val ) {
jQuery.ajaxSetup ({ cache: false });
var row = $(this).closest('tr');
$(row).load('dt_getactivity.php');
}
but this doesn't work.
Can you guys shed some light on how to dynamically load this content?
Thanks in advance,
Tony
This discussion has been closed.
Replies
The Debug code is ovukug
fnRender isn't executed with the scope of the element, so `$(this)` does not result in a jQuery instance with the table cell - fundamentally that is why this isn't working at the moment.
However, before moving to a solution, more generally - these two points seem incompatible to me:
> loading large database tables
> load a cell with this data using an AJAX lookup
That sounds scary to me! If you have 10'000 rows for example, that's 10'000 Ajax requests. Even if you only have 100 rows, that's still enough to make your sever seriously sweat!
I'd suggest looking for a different solution to this problem if that is possible. What does dt_getactivity.php do? is it something that could be loaded once and then some processing done in Javascript? Or better yet, can you merge the data from dt_getactivity into your data feed?
Regards,
Allan
Thanks for the advice,
Tony