I think it would be great if there will be an option to enable DataTables individual column filtering feature.
The example is here:
http://www.datatables.net/examples/api/multi_filter.html

Maybe we could pass bColumnFilter => TRUE in the datatable_options section of the attributes array to turn this feature on.

Comments

dtengeri’s picture

StatusFileSize
new2.12 KB

I'v attached the patch which extends datatables.js to be able to enable this feature.

tommyent’s picture

subsribe

sachbearbeiter’s picture

subscribe

kelliedelaney’s picture

I have been trying to place this patch in the code without success. Does anyone have any tricks or an example of the updated code?

josephcheek’s picture

This patch adds JS support but does not turn on the bColumnFilter boolean to datatables so that this code will be used. So, this patch won't do anything without more work.

josephcheek’s picture

Issue summary: View changes
StatusFileSize
new5.5 KB

Here is a re-rolled patch that includes code from #2 at https://www.drupal.org/node/980424. I rolled it against 7.x-2.x with DataTables 1.9. Should be fairly easy to port to DT 1.10 or 7.x-1.2.

dqd’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Active » Needs work

Since last patch was rerolled against 7.x-2.x let's collect reviews to get RTBC asap.

dqd’s picture

Status: Needs work » Needs review
dqd’s picture

BTW: I would love to see a follow up D8 latest dev! 1+

dqd’s picture

Can somebody please confirm that this patch still works on D7?

lazzyvn’s picture

i think this patch woudn't work with DT version 10.11.19
there is another issue with stateSave
I suggest this code
The code below is taken almost verbatim from the examples at datatables.net
http://www.datatables.net/examples/api/multi_filter.html

 var datatable = $(selector).DataTable(settings);
if (settings.bMultiFilter) {
            var fPosition=settings.bMultiFilter_position; //header or footer
            datatable.columns().every( function (index) {
              var that = this;
              $( 'input,select', this[fPosition]() ).on( 'keyup change', function () {
                if ( that.search() !== this.value ) {
                  that
                      .search( this.value )
                      .draw();
                }
              });
              //stop ordering with mutil filter
              if (settings.bMultiFilter_position == "header") {
                $('input,select', this[fPosition]()).click(function (event) {
                  event.stopPropagation();
                });
              }
              //load value if stateSave is on
              if(settings.bStateSave && settings.searchCols_data){
                 var value_search=settings.searchCols_data[index].search['search'];
                 if(value_search.trim()){
                   $('input,select', this[fPosition]()).val(value_search);
                 }
              }
            });
          }