"Flexibility" - Using a default datatable then extenting it...

"Flexibility" - Using a default datatable then extenting it...

amurdockamurdock Posts: 10Questions: 0Answers: 0
edited October 2011 in General
Here is what i am trying to do...
I have a web application with many different tables. Some have 15 columns some have 6... you get the idea. What I would like to do is have a "Base call" like:
[code]
var oTable = $('.datatable').dataTable({
"bPaginate": false,
"bProcessing": true,
"bStateSave": true,
"bJQueryUI": true,
"bAutoWidth": false,
"sDom": '<"H"TrCi>t<"F">',
"oTableTools": {
"sSwfPath": "../swf/copy_cvs_xls_pdf.swf",
"sRowSelect": "single",
"aButtons": [
{
"sExtends": "copy",
"mColumns": "visible"
},
{
"sExtends": "copy",
"mColumns": "visible",
"bSelectedOnly": "true",
"sButtonText": "Copy Selected"
},
{
"sExtends": "xls",
"mColumns": "visible"
},
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"mColumns": "visible"
},
{
"sExtends": "print"
}
]
}

}); [/code] and then be able to customize the individual tables (EX Sorting, Grouping, KeyTable) in my application without having to have rewrite the entire method. Is that possible?

Thanks,

-Andrew

Replies

  • amurdockamurdock Posts: 10Questions: 0Answers: 0
    Any help?
  • GregPGregP Posts: 495Questions: 9Answers: 0
    edited October 2011
    Yup. The DataTables initialization just takes a parameter map (an object literal, actually... since it can have nested functions etc... I should update the post) as an argument. And this can be easily extended. I wrote a wee little blog post about it if it's helpful to you at all:

    http://gregpettit.ca/2011/reusable-jquery-datatables/
  • amurdockamurdock Posts: 10Questions: 0Answers: 0
    Thank you Greg that will certainly help.

    I guess this is a follow up question. I have a page with 4 tabs, and each tab has a different table with different options. I want to to a FilterAll across all 4 tables but the options for the datatables needs to be different for each table.

    FilterAll uses the oTable.Filterall( ); so how could i customize the tables and still use the FilterAll?
  • amurdockamurdock Posts: 10Questions: 0Answers: 0
    edited October 2011
    I have the same question with fnUpdate().

    If I try to update the second table on the page fnUpdate() or fnGetPosition() will not work.
This discussion has been closed.