Multiple Tables and AJAX source (table identification)
Multiple Tables and AJAX source (table identification)
DestiaTraffic
Posts: 4Questions: 0Answers: 0
Hi!
Excellent Plugin, first of all!
I've created 4 tables (in JQuery UI tabs) with identical settings. Now, they all would need to have content fetched from an AJAX source.
How do I get some sort of an ID of which table I'm creating with
[code]
oTable = $('.dataTable').dataTable( {
[/code]
so that I can go on with
[code]
"sAjaxSource": '/gui_draft/functions/do_table_content_ajax.php?id='+WHAT_TO_PUT_HERE+'&calledfrom=js',
[/code]
and with what function & paeams do I go out to update the content from the sAjaxSource for the individual tables.
Tuomo
Excellent Plugin, first of all!
I've created 4 tables (in JQuery UI tabs) with identical settings. Now, they all would need to have content fetched from an AJAX source.
How do I get some sort of an ID of which table I'm creating with
[code]
oTable = $('.dataTable').dataTable( {
[/code]
so that I can go on with
[code]
"sAjaxSource": '/gui_draft/functions/do_table_content_ajax.php?id='+WHAT_TO_PUT_HERE+'&calledfrom=js',
[/code]
and with what function & paeams do I go out to update the content from the sAjaxSource for the individual tables.
Tuomo
This discussion has been closed.
Replies
You can use the $.fn.dataTableExt.iApiIndex ( http://datatables.net/development/ ) to change which table the API functions are to be operated on. So for example:
[code]
// Use third table
$.fn.dataTableExt.iApiIndex = 2;
// Set Ajax source
oTable.fnSettings().sAjaxSource = "whatever"l
[/code]
It might even be best to use the fnReloadAjax() API plug-in. Don't think I've ever tried it with multiple tables, but it should work... :-)
Regards,
Allan
Got this to work perfectly.
Is there a example of how to use this plugin $.fn.dataTableExt.iApiIndex
I also have a similar problem i.e. I have 2 datatables in a page with different sAjaxSource and both are initialized on load of the page in ready().
What's happening is that, the result of second comes first and tries to fill in the first table with different columns and hence causing the JSON format error.
@Allan is there any api as sAjaxManager as the similar is with jQuery?
It would be great if you provide a link for example of the above.
Regards,
Manohar
If you want, you can control the Ajax request using the fnServerData callback function: http://datatables.net/usage/callbacks#fnServerData
Allan
In this I have created a common jsp i.e. getAjaxData.jsp to handle all calls with different requirements passed on as parameter. This returns JSON formatted output.
Heres the code
[code]
$(document).ready(function() {
$('#showDepFunding').dataTable({
"sAjaxSource": "<%=request.getContextPath()%>/common/getAjaxData.jsp?indentSeqId=<%=indentSeqId%>&requirement=GETACCDTLS_DEP",
/*"oLanguage": {"sProcessing": "Loading data in real time"},*/
"bProcessing": true,
"bInfo":false,
"bFilter":false,
"bPaginate":false,
"sScrollY": 200,
"sScrollX": 900
});
$('#showProjFunding').dataTable({
"sAjaxSource": "<%=request.getContextPath()%>/common/getAjaxData.jsp?indentSeqId=<%=indentSeqId%>&requirement=GETALLPROJS_WITH_ACCDTLS",
"bInfo":false,
"bFilter":false,
"bPaginate":false,
"sScrollY": 200,
"sScrollX": 900
});
});
[/code]
Regards,
Manohar
Allan