1

I use angular 5 and angular-datatable.

I want to apply "btn btn-success" class on custom button

This is what I tried :

this.dtOptions = {
     ...
 buttons: [
     {
       text: 'Sélection',
       className: 'btn btn-success',
       ...
     }
  ]
}

This is the result : enter image description here

The class is added but it keeps 'dt-button' class before that overrides some attributes as you can see on image

But I don't find how to remove it...

How can I solve it ?

2 Answers 2

2

Ok I found :

 this.dtOptions = {
 dom: 'Blfrtip',
 initComplete:  function (settings, json) {
    $('.button').removeClass('dt-button');
 },
 buttons: [
    'print',
    'excel',
     {
          text: 'Sélection',
          className: 'table-button button btn btn-success',
          ...
        }
     ]
}

Now It works !

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar issue in Angular 13 and Bootstrap 5 and was able to resolve it as follows:

initComplete: function (settings: any, json: any) {

    $('button').removeClass('dt-button');
    $('button').removeClass('buttons-excel');
    $('button').removeClass('buttons-html5 ');
      
  },
  buttons: [{
    extend: 'excel',
    text: 'Exportar',
    className: "btn btn btn-dark float-end",
  }],

button color change

If the styles are not removed first, the one you want to apply does not apply.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.