Searching with render function...
Searching with render function...
Hi,
I am using Datatables with ajax calling a server side script to get the result-set from a MySQL database. For some of the columns, I need to modify the text that needs to be displayed e.g.
data: null,
render: function ( data, type, row, meta ) {
return row.manufacturer + " (" + row.model + ")";
}
The column correctly displays the text. But when I try to search for either the manufacture or model, no results come up. I am searching from the UI using the Datatables builtin input box. Any idea how can I include the manufacturer and/or model in the search?
Many Thanks!
This question has an accepted answers - jump to answer
Answers
Hi @n000b19 ,
When
serverSide
is enabled, all searches are performed there, so how you render the data on the client would have no bearing, you would need to do the same search on the server side too.Hope that helps,
Cheers,
Colin
Thanks Colin.
If I do like
Then the search does return any manufacturers matching the input. I am wondering, if there is a way to define two db columns (manufacturer is column in db, as is model, in the same table) for the data, something like (which does not work )
I don't do much with server side processing but maybe you can create table columns for
manufacturer
andmodel
then hide them usingcolumns.visible
. They won't be visible and you can still display the combined using your above column definition. The thought is that the hidden columns would be sent with the other parameters to your server side processing script.Kevin
Thanks kthorngren!
I think that approach should work . I'll accept your comment as the answer.