How to set "active" property of a extended columnVisibility button for all-columns-visible action ?

How to set "active" property of a extended columnVisibility button for all-columns-visible action ?

Alper YAZGANAlper YAZGAN Posts: 7Questions: 2Answers: 0

I just want to ask if there is a way of dataTable way of this ?
I have column visibility button group like the following (generated from the following php code, I think you can guess that what is like in js)


    [
        'extend'         => 'colvis',
        'columns'        => ':gt(0)',
        'postfixButtons' => [
          'colvisRestore',

          [ 
            'extend'     => 'columnVisibility',     //  Button Show All   
            'className'  => 'buttons-columnVisibility-showAll',
            'text'       => 'function (dt) { return dt.i18n(\'buttons.columnVisibilityAll\', \'Show All Columns\'); }'
            'visibility' => true,
          ],
        ],

      ]

This button (last one) has always get the "active" class when it is rendered, but it is not bound to a column but columns, there is no indicator that it is activated or else in my opinion;
so my question is whether there is a "chic" dataTable way of achieving to activate (get active class or not) only when it has some certain condition ?

Any comments will be greatly appreciated.
Regards,

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590
    Answer ✓

    I don't quite follow, but this recent example here is using button().active() to change the active state.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Alper YAZGANAlper YAZGAN Posts: 7Questions: 2Answers: 0

    Thank you, your reference was helpful indeed.

    To simplify at most; My question was, if you extend a button from columnVisibility as described in my example to enable all the columns, with or without any interaction the button is always active (and there is no functional problem it is working). From your reference I concluded that I should define my action function without relying on the default to change the active state.

Sign In or Register to comment.