TableTools Custom Button Help
TableTools Custom Button Help
morrty
Posts: 29Questions: 6Answers: 0
Is there an easy way to just create a custom button beside one of the preset buttons that simply links to a static URL.
Basically, I just want a button that links to a different page on my site but I want to keep the current CSS and style of TableTools buttons. I didn't want to go fooling around in CSS to mimic something if there is a built in way for me to do it with TableTools.
Thank you.
Basically, I just want a button that links to a different page on my site but I want to keep the current CSS and style of TableTools buttons. I didn't want to go fooling around in CSS to mimic something if there is a built in way for me to do it with TableTools.
Thank you.
This discussion has been closed.
Replies
[code]
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [
{
"sExtends": "copy_to_div",
"sButtonText": "Copy to div",
"sDiv": "copy",
}
]
}
} );
} );
[/code]
http://www.datatables.net/release-datatables/extras/TableTools/plug-in.html
I haven't done this myself, but it seems straightforward in the example code.
[code]
$(document).ready(function() {
$('#datatable').dataTable( {
"aaSorting": [[0,'asc']],
"iDisplayLength": 15,
"aLengthMenu": [[15, 50, 100, -1], [15, 50, 100, "All"]],
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "../swf/copy_cvs_xls_pdf.swf",
"aButtons": [ "xls", "print" ],
"aButtons": [ {
"sExtends": "edit",
"sButtonText": "Edit",
"sUrl": "?e=edit"
} ]
}
} );
} );
[/code]
[code]
TableTools.BUTTONS.gotoURL = {
"sAction": "text",
"sFieldBoundary": "",
"sFieldSeperator": "\t",
"sNewLine": "
",
"sToolTip": "",
"sButtonClass": "",
"sButtonClassHover": "",
"sButtonText": "Go to URL", // default, change when initiating
"sGoToURL": "", // default, change when initiating
"mColumns": "all",
"bHeader": true,
"bFooter": true,
"fnMouseover": null,
"fnMouseout": null,
"fnClick": function( nButton, oConfig ) {
location.href = oConfig.sGoToURL;
},
"fnSelect": null,
"fnComplete": null,
"fnInit": null
};
[/code]
[code]
'aButtons'=>array(
array(
'sExtends'=>'collection',
'sButtonText'=>'My Buttons',
'sButtonClass'=>'DTTT_button_mod',
'sButtonClassHover'=>'DTTT_button_mod',
'aButtons'=>array('copy','csv','xls','pdf','print',
array(
'sExtends'=>'gotoURL',
'sButtonText'=>'Example.com',
'sGoToURL'=>'http://example.com',
),
)
)
[/code]
Good luck,
Son Nguyen