Hide a custom button collection after initComplete doesn't work
Hide a custom button collection after initComplete doesn't work
itajackass
Posts: 162Questions: 48Answers: 3
I need to hide some buttons not needed based on query variable url.
I've this but doesn't work (but alert is fired correctly):
"initComplete": function(settings, json) {
alert( 'DataTables has finished its initialisation.' );
// HIDE
var type = getParams(window.location.href)['type'];
if ( type != "ddt" ) {
alert("I'm going to hide");
$(".dt_btn_ddt_converti_fattura").css("display","none");
}
},buttons: [
{
extend: 'collection',
text: 'Selected',
buttons: [
{
text: 'DDT: Trasforma Fattura',
className: 'dt_btn_ddt_converti_fattura',
action: function () {
...
}
},
{
text: 'Invoice: Set done',
className: 'dt_btn_fattura_done',
action: function () {
...
}
}
]
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi itajackass,
I just tried it here, and it works for me - I'm hiding the XLS button in initComplete.
So it's something to do with the test you have around the hide action - the
type != "ddt"
. I'd say debug those values, as the hiding itself will work!Cheers,
Colin
Hi, thanks for the reply. My problem is when the button is inside a COLLECTION. See your code updated. http://live.datatables.net/pusowihu/1/edit
Making progress!
There's two lines now in the initComplete - one disables the buttons (
button().disable()
), the other removes them entirely (button().remove()
).button().add()
can be used to re-add it again.I hope that does the trick!
C
Wow it's perfect! Thanks!!!!