change filter/search input field for multiple columns

change filter/search input field for multiple columns

ianhaneyianhaney Posts: 19Questions: 4Answers: 0
edited November 2023 in Free community support

I had a web based system built for me by a developer who done it using Laravel coding and on one page is a list of customers and it has a search input field, it's using datatables which looks like it filters usernames column only when I enter text into the search field but I would to be able to include the contact column as well so I can search for phone numbers as well as username. Could someone help me please and help me with what I need to amend to include the contact column

Below is the code I found that I think is related to the table

<table id="dataTable" class="table zero-configuration ">
<thead>
<tr style>
<th>ID</th>
<th>Registration Date</th>
<th>Username</th>
<th>Contact</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

<script type="e38309f204b106606a1bc70a-text/javascript">
   var table = $('#dataTable').DataTable(
    {
        "responsive" : true,"autoWidth"  : false,
//        "ordering": false,"paging" : true,
        "processing" : true,"serverSide": true,
//        "columnDefs": [{ responsivePriority: 1, targets: 0 }],
        "ajax":
            {
                "url":"https://newadminsystem.it-doneright.co.uk/user/list-customer","dataType":"json","type":"POST",
                "data": function ( d )
                {
                    d._token= $('meta[name="csrf-token"]').attr('content');
                }
            },
        "columns":[
        {"data":"a"},{"data":"b"},{"data":"c"},{"data":"d"},{"data":"e"},{"data":"f","searchable":false,"orderable":false}
    ],
        "order": [[0, 'desc']]   
});
</script>

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

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    The filtering should work on all columns automatically. If it's not, the problem will be your ajax script - you've enable serverSide, so the server is performing searching (and paging and ordering). Take a look at that script and see if there's anything obvious in there.

    Colin

Sign In or Register to comment.