how to set columns for search datatables jquery
how to set columns for search datatables jquery

how to set columns for search datatable jquery? i use datatables and my problem is filter multi columns.
i am trying filter all columns in DataTables but only last field send to server for filtering.
function searchRow(selector, formName) {
var $formId = $('#' + formName + 'Form');
var formData = new FormData( $formId[0] );
for (var pair of formData.entries()) {
table.column(pair[0]).search(pair[1]);
}
table.ajax.reload();
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I don't immediately see any problem with that code. Could you create a test case on http://live.datatables.net or give me a link to some other page that shows that issue please.
Allan
address in live is:
http://live.datatables.net/camucuka/1/edit
This is obvious
This only searches the last field
Not sure why but in your test case the
pair
variable doesn't seem to populate with the values in the inputs. But the example does highlight what you are tying to do, I think. I added a console log statement to see how theformData
loop is working:http://live.datatables.net/camucuka/2/edit
I updated your test case using the server side example provided in this technote. I also manually created an array for the loop (didn't want to take the time to debug the formData you are using).
http://live.datatables.net/cuxolaxa/1/edit
With two column searches defined:
You can see both search values are sent to the server:
Also you will want to use
draw()
instead ofajax.reload()
to perform the search.Kevin
thankyou allan , I could do it with your guidance
http://live.datatables.net/qadoxalu/5/edit
Hi @mamadsoli ,
That link looks like it's behaving to me - I corrected the column headings here. Where do you think it's not behaving?
Cheers,
Colin
hi dear friend
you use draw() instead of ajax.reload() .
Anyway thank you very match.