DataTables with different types of filtering options on the same table

DataTables with different types of filtering options on the same table

CardscaleCardscale Posts: 5Questions: 3Answers: 0

Hi, I am new to DataTables and slowly working my way through the documentation and assistance you provide via the examples and forum.

I have created a DataTables table and I currently have dropdown filtering on all of the columns.

JSFIDDLE

The issue I have is that I need to remove some of the filtering all together and replace some of the other dropdown filtering methods with simple text input filtering boxes.

Firstly, I need to remove the filtering from the first column ('id'). I do not want filtering or search on this column at all.
Secondly, I want to replace the existing dropdown filter in the second column ('Name') with a simple text input search filter.

Any help would be greatly appreciated as I have been pulling my hair out as to how to do this over the last few days.

Regards
Alan

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    This example shows a combination of select and input elements. - it's in the footer but the same principle applies. The imported thing to consider is line 7,

                $('.filterhead', api.table().footer()).each( function (i) {
    

    that's saying every element, use a selector that only returns the ones you want to put a select into,

    Colin

  • CardscaleCardscale Posts: 5Questions: 3Answers: 0

    Hi Colin,
    Thanks very much for your feedback, I now have the search and select filtering working.

    My next step is to get the select filters to be 'dynamic', by this I mean in my fiddle below if I select 'IT Developer' as the Position, I want the remaining select dropdown(s) to be filtered by selected options. i.e. when selecting 'IT Developer' as the position the office dropdown should only show 'Coventry' and 'Liverpool not all 5 of the available offices ( Coventry, Edinburgh,Liverpool, San Francisco,Tokyo)

    My JSFiddle

    In a nutshel, all of the select dropdown need to work like this example http://live.datatables.net/segubole/139/edit

    In the example above if you select the Software Engineer as the position, then the office dropdown only shows 4 cities rather than all of them.

    If all of my column filters were dropdown I could cut and paste the solution from the example above but my table has both text and dropdown filters and I really don't know where to start in terms of applying the solution to my existing code.

    Again, thanks for you great support, time and efforts I really appreciate it.

    Regards

    Alan

  • kthorngrenkthorngren Posts: 21,542Questions: 26Answers: 4,988

    See Allan's example from this thread for cascading select filters.

    Kevin

This discussion has been closed.