• Resolved caa5042

    (@caa5042)


    I disabled the default search and i’m using a custom filter for my table. i want the first row of the table to always be displayed even if it doesn’t meet the filtering criteria. how do i do this? here’s my code:

    jQuery(function($) {
    $.fn.dataTable.ext.search.push(
    function( settings, data, dataIndex ) {
    var searchTerm = $(‘#searchBar’).val();
    console.log(searchTerm)
    var others = data[13]
    var modelVerb = data[0]
    if ( others.includes(searchTerm) || modelVerb.includes(searchTerm))
    {
    return true;
    }
    return false;
    }
    )
    });

    jQuery(function($) {

    $(document).ready(function() {
    var table = $(‘#tablepress-10a’).DataTable({
    dom: ‘l’,
    paging: false,
    ordering: false,
    searching: true
    });

    // Event listener to the filtering input to redraw on input
    $(‘#searchBar’).keyup( function() {
    table.draw();
    });

    });

    });

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I’m not too experienced with the DataTables JS library’s API functions. I can therefore only suggest to ask about this in the DataTables forums, as this is not really specific to TablePress.

    Regards,
    Tobias

    Thread Starter caa5042

    (@caa5042)

    thanks. they responded quickly.

    i had to also check if the parameter dataindex==[the row that i want excluded from filtering] and return true. in case someone else is trying to do custom filtering.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great! Good to hear that you have a solution now! ??

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Datatalbles: How to exclude specific row from filter?’ is closed to new replies.