Show custom button according custom option
Show custom button according custom option
rodriformiga
Posts: 47Questions: 12Answers: 0
Hello
I created a custom button instance to use in page navigation, for example, and I would like this button to only appear according to an option that I create in my application (some tables may not have the option to go back, for example. example).
I intend to automatically add the button to the table at startup if that property is active.
it is possible? What callbak or event can I use to encode this?
Example:
My button:
$.fn.dataTable.ext.buttons.back = {
text: 'Back'
, className: "dt-button-nav-back"
, action: function ( e, dt, node, config ) {
alert("back to:"); //need to read the custom property here and execute a action
}
};
And my code:
$(document).on( "preInit.dt", function (e, settings) { //this or another event???
if (settings.backUrl){
//ADD here the code to add/show the back button
}
});
$("#myTab").DataTable({
"ajax": {"url": "loadData.php", type: "POST" }
, "backUrl": "searchData.php"
, buttons: [ "print", "excel", "colvis"] //I don´t add button here, because it depends of a property
, "columns": [
{ "data": "cd", title: "ID"}
,{ "data": "nu", title: "Code" }
,{ "data": "no", title: "Name" }
,{ "data": "fl", title: "Active" }
,{ "data": "tp", title: "Type" }
,{ "data": "dt", title: "Data" }
,{ "data": "hr", title: "Hour" }
,{ "data": "vl", title: "Value" }
]
});
This discussion has been closed.
Answers
someone please!? help!?
Yeeess!! I do...
My solution: