How can I remove default button class of Datatable (btn-default)
How can I remove default button class of Datatable (btn-default)
I am using Data table with Button. I want to show Success button rather default.
I tried this Code
buttons: [
{
extend: "excel",
className: "btn-sm btn-success",
titleAttr: 'Export in Excel',
text: 'Excel'
}]
This code is working but this is adding btn-success class, But I want first remove the btn-default class then add the success class.
Current Classes: "btn btn-default buttons-excel buttons-html5 btn-sm btn-success"
What I want: "btn buttons-excel buttons-html5 btn-sm btn-success"
Answers
Hi,
Its being added here - and the class names are additive. So what we need to do is remove it from the defaults:
should do it.
Allan
Hi Allen,
When I do this:
editor
.title( '' )
.message( "are you sure" )
.buttons( [
{
"className": 'btn-link',
label: "delete",
fn: function () {
cat_editor.submit();
}
}
])
.remove( $(this).closest('tr') );
Then the button on the popup has the class: "btn btn-default btn-link".
This always happens, even if I do: $.fn.dataTable.Buttons.defaults.dom.button.className = 'btn';
Is there a way that I can not have the "btn-default" class there?
Regards,
Marcel
Hi Marcel,
Yes - use:
before you initialise the Editor. That should resolve it in this case. Its Editor that is adding the
btn-default
class.Allan