Group/Filer with Buttons

Group/Filer with Buttons

cklaslancklaslan Posts: 2Questions: 2Answers: 0

I would love to duplicate the group feature of this page https://www.datatables.net/reference/option/
The entire datatable is presented at first but multiple buttons can be pressed/unpressed to show/hide mutilple row groups. How can this be duplicated?

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    Not too hard to do. You need an onClick or onChange event that fires a call to DT's filter.

    I have a page with a radio button, so in addition to the radio button HTML, I have this.

    $("input[name='year']:radio").change(FilterData);
    

    later on the page I have this

    function FilterData(){
       var valSelected = $("input[name='year']:checked").val();
       myDataTable.column([3]).search(valSelected).draw();
    }
    

    Columns are zero based indexed, so my 4th column is the year I am filtering by.

This discussion has been closed.