ColumnControl - Clear Search button not enabling on search

ColumnControl - Clear Search button not enabling on search

yajrayajra Posts: 25Questions: 1Answers: 1

Using the same example as https://datatables.net/extensions/columncontrol/examples/search/clearAll.html, the clear button doesn't get enabled when doing a column search.

dt.columns().every(function () {
    // this always returns null
    if (this.search.fixed('dtcc') || this.search.fixed('dtcc-list')) {
        enabled = true;
    }
});

Any advice on what might have caused the issue? Thanks!

Replies

  • yajrayajra Posts: 25Questions: 1Answers: 1

    As a workaround, I just created a custom reset button that is always enabled.

    $.fn.DataTable.ext.buttons.reset = {
        name: 'reset',
        className: 'btn-secondary',
        titleAttr: 'Reset',
        text: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>',
        action: function (e, dt, button, config) {
            dt.search('');
            dt.columns().columnControl.searchClear();
            dt.draw();
        }
    };
    
    
  • allanallan Posts: 65,162Questions: 1Answers: 10,796 Site admin

    Hi,

    Just to confirm - the example appears to be working okay. Is it for you?

    Assuming that is the case, can you link to a page showing the issue?

    Allan

  • yajrayajra Posts: 25Questions: 1Answers: 1

    @allan Yes, the example is working fine. I will try to have a test case link when I get the chance.

    Thanks!

Sign In or Register to comment.