Combining Three columns In Search
Combining Three columns In Search
{
data:'first_name', name:'first_name',
render: function(data, type, row, meta) {
return `
${row.first_name} ${row.middle_name}
${row.last_name}
`
}, className: 'dt-left, dataTableLeftAlignment', searchable: true, sortable: false
},
I am displaying first_name , middle_name , last_name in one column but it searches for first_name only , how can I let it search by first_name,middle_name,last_name ?
This discussion has been closed.
Answers
Hi @abdallahbedir ,
That should work fine, see this example here. Can you take a look at my code and see if that helps, and if not, could you create a similar problem demonstrating the problem, please.
Cheers,
Colin
Hi @colin ,
Actually It didn't work like your example , I think because my case is a bit different as I have
nameproperty different thandata, the below code shows onlyfirst_nameresults when I start searching :{
data:'first_name', name:'clients_translations.first_name',
render: function(data, type, row, meta) {
return
${row.first_name} ${row.middle_name} ${row.last_name} }, className: 'dt-left, dataTableLeftAlignment', searchable: true
},
If I changed the code to
middle_name, it searches only formiddle_name.Thanks
Would you be able to create a live example, that would help to understand this?
C
Yes @colin , just add
"serverSide": true,to your example and you will find the issueGotcha... take a look at this example here - the problem is because it's not a configured column, it's not part of the search data. I've added the
last_nameas a hidden column, and now the searches work as expected.Does that work for you?
Thanks @colin for the workaround but It's not an efficient solution because If you searches for both
first_name&last_namewill not work .As it is, it's not going to be possible. The server-side script searches based on the columns that match the
dataparameter, and it can't search on the rendered data, since that only works with client-side processing.So, you'll either need to modify the server-side script to support searching across parameters, or switch to client-side processing.