Change default class modification from initialization or callback method

Change default class modification from initialization or callback method

BenjaminGBenjaminG Posts: 2Questions: 0Answers: 0

Hi there,

I would like to be able to update classes from this :

sFilterInput: "form-control form-control-sm", sLengthSelect: "form-control form-control-sm",

to this :

sFilterInput: "form-control", sLengthSelect: "form-control",

Inside datatable initialization or callback method.

I'm using datatable 1.10.6 with Boostrap 4.

Any thoughts ?

Thanks.

Ben.

Replies

  • rf1234rf1234 Posts: 2,937Questions: 87Answers: 415
    edited February 2018
    yourTable
    .on ('preInit', function (e, settings) {
        $('.form-control').removeClass('form-control-sm'); 
    })
    

    if that doesn't work you might want to try the "init" event.

    Here is the event documentation: https://datatables.net/reference/event/

    You can of course also use the api instead of using plain jQuery. But actually I wouldn't know how to do this really.

  • BenjaminGBenjaminG Posts: 2Questions: 0Answers: 0

    Hi, thanks for the reply.

    Regarding the api, I didn't manage to make it work so I don't know.

    I finally did it with simple jQuery.

This discussion has been closed.