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 to remove the btn-default class first and 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"
You should take a look at the
buttons.dom.button
option.This will give you total control on how the button will be rendered in the DOM. No need to remove any classes afterwards.
Here is an example.
Maybe this can help
Add this to jquery after loading Datatables
Or you can make your own css class and mark the require attributes as !important to override the default style
Use this code to hide Excel text on button:
Yes, this can be really annoying. It is the same without using bootstrap, where
.dt-button
always is added even if you declareclassName
. There is ainit
callback you can use to modify for example classes :demo -> https://jsfiddle.net/m6hysypd/
Update: Have received a lot of upvotes on this, but the correct or best answer is actually "DavidDomains"'s answer below. Use