Guide to search columns in laravel-datatables with package yajra/laravel-datatables

Tram Ho

Link install package here:

In the HTML plugin we use Events/Callbacks to generate search inputs corresponding to each column and catch the search logic event of each input. the code will be as follows:

With the above code I use the event callback initComplete to run 2 pre-set js functions outside the view. The code of the two functions is as follows:

With the above js function, it will perform the function of rendering the inputs into columns 1, 2, 3 into the footer and catch the onchange event on each input to search with the keyword and return the records by keyword on each column. With the$(this).val(), false, false, true).draw() paragraph, go to the datatable’s docs with detailed instructions.

Here to catch the keyword search by column, in the controller you have to use DI. the code is as follows

With class BuildingDataTable We create with instructions in the following link:

Good luck !

Share the news now

Source : Viblo