datatables and many to many relations
datatables and many to many relations
Hi. My server returns the following json response:
{
"sEcho":1,
"iTotalRecords":1,
"iTotalDisplayRecords":1,
"aaData":[
{
"id":"1",
"first_name":"asdasdasd",
"last_name":"asdfasdfasdf",
"email_address":"sdfasdfasdf@asdfasdf",
"username":"sdfasdf",
"Profile":{
"id":"1",
"phone":"0722734132",
"pic":"asdasdasd.jpg",
"user_id":"1"
},
"Permissions":[
{"id":"1","name":"profi","description":"This person has role of profi","created_at":"2013-06-17 22:21:46","updated_at":"2013-06-17 22:21:46"},
{"id":"2","name":"partner","description":"This person has role of partner","created_at":"2013-06-17 22:21:46","updated_at":"2013-06-17 22:21:46"}
]
}
]
}
as you can see Profile is a 1 to 1 relatin so if i configure a datatable column with mdata: Profile.phone it will just show it correctly. Also the searching and indexing works corectly for this relation.
The problem is for the permissions. As you see this is a collection of stuff because there is a many to many relation between my user table and the permissions table.
Question is ... how can i configure the Permissions column so that is just shows all the permissions by name for example ? Also how can i make it so that search works properly ? I can't just configure the mdata Permissions.name :(
{
"sEcho":1,
"iTotalRecords":1,
"iTotalDisplayRecords":1,
"aaData":[
{
"id":"1",
"first_name":"asdasdasd",
"last_name":"asdfasdfasdf",
"email_address":"sdfasdfasdf@asdfasdf",
"username":"sdfasdf",
"Profile":{
"id":"1",
"phone":"0722734132",
"pic":"asdasdasd.jpg",
"user_id":"1"
},
"Permissions":[
{"id":"1","name":"profi","description":"This person has role of profi","created_at":"2013-06-17 22:21:46","updated_at":"2013-06-17 22:21:46"},
{"id":"2","name":"partner","description":"This person has role of partner","created_at":"2013-06-17 22:21:46","updated_at":"2013-06-17 22:21:46"}
]
}
]
}
as you can see Profile is a 1 to 1 relatin so if i configure a datatable column with mdata: Profile.phone it will just show it correctly. Also the searching and indexing works corectly for this relation.
The problem is for the permissions. As you see this is a collection of stuff because there is a many to many relation between my user table and the permissions table.
Question is ... how can i configure the Permissions column so that is just shows all the permissions by name for example ? Also how can i make it so that search works properly ? I can't just configure the mdata Permissions.name :(
This discussion has been closed.
Replies