i want to remove certain fields from search bar

i want to remove certain fields from search bar

zaeem syedzaeem syed Posts: 1Questions: 1Answers: 0
edited February 15 in DataTables 1.10

i am using datatables and i want to remove some fields from datatable search bar .
currently it is search is applied on all the all the fields on headers
i want to remove some fields from search bar

$(document).ready(function () {
    // Setup - add a text input to each footer cell
    $('#example thead tr')
        .appendTo('#example thead');

    var table = $('#example').DataTable({
        orderCellsTop: true,
        fixedHeader: true,
        initComplete: function () {
            var api = this.api();

            // For each column
                .each(function (colIdx) {
                    // Set the header cell to contain the input element
                    var cell = $('.filters th ').eq(
                    var title = $(cell).text();
                    $(cell).html('<input type="text" placeholder="' + title + '" />');

                    // On every keypress in this input
                        $('.filters th').eq($(api.column(colIdx).header()).index())
                        .off('keyup change')
                        .on('keyup change', function (e) {

                            // Get the search value
                            $(this).attr('title', $(this).val());
                            var regexr = '({search})'; //$(this).parents('th').find('select').val();

                            var cursorPosition = this.selectionStart;
                            // Search the column for that value
                                    this.value != ''
                                        ? regexr.replace('{search}', '(((' + this.value + ')))')
                                        : '',
                                    this.value != '',
                                    this.value == ''

                                .setSelectionRange(cursorPosition, cursorPosition);


Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.


  • colincolin Posts: 14,448Questions: 1Answers: 2,462

    On line 16, where you have columns(), specify the columns that you want columns(), something like columns([1,2]) for example,


Sign In or Register to comment.