I don't understand how to use a Nested data object array mixed data
I don't understand how to use a Nested data object array mixed data
kabeda
Posts: 6Questions: 1Answers: 0
Hi,
I have data received form Server-side processing way.
It get this kind of row data :
{
"id": 67,
"nom": "Amir Parker Jr.",
"email": "leda94@keeling.com",
"actif": "<span class=\"glyphicon glyphicon-ok text-success\"> </span>",
"parent": "Murl Kessler",
"roles": [
{
"id": 4,
"name": "Commercial",
"categorie": "A",
"order": 4,
"created_at": "2017-03-14 12:58:38",
"updated_at": "2017-03-14 12:58:38",
"pivot": {
"user_id": 67,
"role_id": 4
}
}
],
"action": "<a href=\" http://satisf.loc/gestion/users/67/edit\" class=\"btn blue btn-xs\"> <i class=\"fa fa-edit\"></i> Modifier </a>"
},
In my javascript, I have
"columns": [
{data: 'nom'},
{data: 'email'},
{data: "roles.0.name"},
{data: 'parent'},
{data: 'actif', className: 'dt-center'},
{data: 'action', orderable: false, searchable: false}
],
Every thing worked well before until I added the column 2 (role). I have [object Object] and I can't use the ordering option.
How I could retrieve the data form this nested object/array?
Thanks
This discussion has been closed.
Replies
You need to use the array syntax of the
columns.data
option. For exampledata: 'roles[, ].name'
.Allan
Thanks allan,
It works but as if I use {data: "roles.0.name"} it gave me the same error when I try to reorder this column.
and I got SQL error
Do I have to disable the order by orderable: false or could the order works with some other method?
Are you using the Editor PHP or .NET libraries here?
Yes, you probably will need to disable sorting on that column. Certainly the Editor libraries don't support sorting MJoined columns when server-side processing is enabled.
Allan