jQuery DataTables - Filter column by exact match

前端 未结 9 2512
感动是毒
感动是毒 2020-11-27 18:06

Trying to only display exact matches to the search term entered in the search bar.

For instance, I have a search bar that filters by ID#. I want only records that m

9条回答
  •  没有蜡笔的小新
    2020-11-27 18:41

    If you want the exact match from the beginning you can try this code,

        var table = $('#myTable').DataTable()
        $('#filterrow > th:nth-child(2) > input').on( 'keyup change', function () {
            table
            .column( $(this).parent().index()+':visible' )
            .search( "^" + this.value, true, false, true )
            .draw();
        } );
    

提交回复
热议问题