mRender function get data from another column
mRender function get data from another column
fearednerd
Posts: 44Questions: 0Answers: 0
I am trying to create a hyperlink with mRender. Unfortunately I need the name and the id which are in 2 different fields in the json.
Basically the json is like
[code]
{
"aaData": [
{
"id": 1,
"model": "ccc.changerequest",
"fields": {
"name": "aa",
"post_time": "2013-08-21 17:12:37",
"risk_1": "a",
"delivery_manager": "pyi1",
"staging_datetime": null,
"author": 2
}
},
]}
[/code]
I was wondering if there was anyway so I could get mRender to get both the Id and field.name to create the link.
i tried setting the mdata for a column to be field.name and another to be the id and use mrender function to return data + " " + row[id row] but with no success.
Any help/advice is greatly appreciated.
Willing to post any more information if it will help.
Basically the json is like
[code]
{
"aaData": [
{
"id": 1,
"model": "ccc.changerequest",
"fields": {
"name": "aa",
"post_time": "2013-08-21 17:12:37",
"risk_1": "a",
"delivery_manager": "pyi1",
"staging_datetime": null,
"author": 2
}
},
]}
[/code]
I was wondering if there was anyway so I could get mRender to get both the Id and field.name to create the link.
i tried setting the mdata for a column to be field.name and another to be the id and use mrender function to return data + " " + row[id row] but with no success.
Any help/advice is greatly appreciated.
Willing to post any more information if it will help.
This discussion has been closed.
Replies
[code]
mData: 'id',
mRender: function ( data, type, row ) {
return row.field.name +' '+ row.id;
}
[/code]
Allan
[code]
"aoColumns": [
{"mData": "fields.name"},
{"mData": "id"}
],
"aoColumnDefs": [
{
"mData":"fields.name",
"aTargets":[0],
},
{
"mData":"id",
"mRender": function(data, type, full) {
return fields.name + " " + id;
},
"aTargets":[1]
}
]
[/code]
This is what I have.
Allan
I changed it to return full.fields.name+ " " + data;
Everything works now. Thanks once again.