Individual column searching & filtering (select / input in the table header / footer)

Created on 30 October 2019, about 5 years ago
Updated 18 January 2023, almost 2 years ago

How can I use the "Individual column searching" function for Drupal 8? I have seen that there is a patch for Drupal 7.

Thx

https://www.datatables.net/examples/api/multi_filter.html

jQuery(document).ready(function() {
  // Setup - add a text input to each footer cell
  jQuery('#datatable tfoot th').each( function () {
    var title = jQuery(this).text();
    jQuery(this).html( '<input type="text" placeholder="Search '+title+'" />' );
  } );

  // DataTable
  var table = jQuery('#example').DataTable();

  // Apply the search
  table.columns().every( function () {
    var that = this;

    jQuery( 'input', this.footer() ).on( 'keyup change clear', function () {
      if ( that.search() !== this.value ) {
        that
          .search( this.value )
          .draw();
      }
    } );
  } );
} );

I have integrated the javascript file into the website. But then I get the following error:

jquery.min.js?v=3.2.1:2 jQuery.Deferred exception: table.columns is not a function TypeError: table.columns is not a function
    at HTMLDocument.<anonymous> (http://landwehrcie.de/themes/contrib/zurb_foundation/js/init_datatables.js?v=8.7.8:12:9)
    at j (http://landwehrcie.de/core/assets/vendor/jquery/jquery.min.js?v=3.2.1:2:29999)
    at k (http://landwehrcie.de/core/assets/vendor/jquery/jquery.min.js?v=3.2.1:2:30313) undefined

Thank you for your help

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany bavramor

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024