Add multiple value in column
Add multiple value in column
pettedemon
Posts: 38Questions: 6Answers: 0
Hi,
I haver a server side Datatables.
when I render my table I want to tie more value in one column.
So I have:
name + email + city
in the script I have just
`
"columns": [
{
"className": 'details-control',
"orderable": false,
"data": null,
"defaultContent": '',
},
{
"data": "ora_appuntamento",
},
{
"data": "numero_telefono",
},
],`
I want add a column with the multiple value. So how can I do it?
Thanks
This discussion has been closed.
Answers
You need a column render function.
https://datatables.net/examples/advanced_init/column_render
Hey @pettedemon , I haven't tested this at all, but the excerpt below should give you a push in the right direction, if you take a look at
columns.render
examples, it should clarify more.Any further questions feel free to ask ^-^
David
@David@Quantum , so I have to change all the column rendering?
I have to change the method of
"colums":[
"data": "ora_appuntamento",
]
What we're doing in the second column here is grabbing the data for the whole row and formatting it into a string that will be put into the column.
Hi @David@Quantum
If I do
I have no render
if I do
The data in second column is not searchable
Hi @pettedemon ,
This example here should get you going, it's showing how to use
columns.render
. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.Cheers,
Colin
Hi @colin ,
the render is fully working, I am server-side Datatables.
the others column are searchable but the column with render is not
in my server-side script I have the data by
so all the columns are searchable by default but not with the render. I try your example and it is fully working
and the data in json are present
Hi @colin ,
if I set my column to null I have not search
If I set
I have only codice_fiscale available in the search
So how can enable all the data searchable? codice_fiscale + nome + cognome
thanks
@pettedemon , I assume that DataTables searches columns based on data rather than actual contents. If you wanted it to be searchable you'd have to chose which value you'd want it to search by and set
"data": null
to that value.Regards,
David
Hi, @David@Quantum
so if I want search all the value?
in the example of @Colin I can search all the value
thanks
Yep, as David said, try setting
data: null
, that's set in my example.HI @colin ,
I try to set but it doesn't work
This thread about server side searching rendered columns hopefully will help:
https://datatables.net/forums/discussion/comment/117363/#Comment_117363
Basically it suggests using this:
and having hidden columns for
nome
andcognome
.Kevin