Multiple tables
Multiple tables
Hello
I have multiple tables on one page. I want to add raw only to the second table. How could I get the object to run fnSort function on this object? How could I use this function dynamically?
I see this: http://datatables.net/examples/basic_init/multiple_tables.html
but it only present the tables without any function (like add raw: http://datatables.net/examples/api/add_row.html).
Thanks for the help.
I have multiple tables on one page. I want to add raw only to the second table. How could I get the object to run fnSort function on this object? How could I use this function dynamically?
I see this: http://datatables.net/examples/basic_init/multiple_tables.html
but it only present the tables without any function (like add raw: http://datatables.net/examples/api/add_row.html).
Thanks for the help.
This discussion has been closed.
Replies
If you are using a single call to initialise multiple tables, you can use the property '$.fn.dataTableExt.iApiIndex' to change which table is used by the API functions (see http://datatables.net/development/ ). For example if $('.data').dataTable(); inits 5 tables, and you want to add data to the 3rd, you would do: "$.fn.dataTableExt.iApiIndex=2; oTables.fnAddData(...);".
Regards,
Allan
Could I call the table object via its id (html id)?
Thanks
You could probably parse through the $.fn.dataTableSettings array of objects to find the settings which correspond to the target table - but I think it's probably much easier if you just use a global variable - or attach it to a global variable.
Regards,
Allan
Probably best to refer to my answer in your other post http://datatables.net/forums/comments.php?DiscussionID=538 . It's possible, but I would very much recommend against it. Is there any reason not to have another variable?
Allan
"sAjaxSource": 'accion.asp',
"fnServerData": function ( sSource, aoData, fnCallback ) {
var id = $(this).attr('sTableId')
aoData.push( { "name": "Accion", "value": id } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
Regards.