mData property with Dot special character
mData property with Dot special character
ssakthiv
Posts: 3Questions: 0Answers: 0
I am using mData in aoColumns to bind the datastore variables to my datatable columns. The problem i have is that the datastore properties pointed by mData have special characters '.' in them, hence datatable is considering it as nested object even though their value is plain string and i am getting "requested datasource name not found.." error.
Related Code:
[code]
"aoColumns" : [
{"sTitle": "Name", "mData": "name"},
{"sTitle": "Package", "mData": "name.package@v1"},
....
]
[/code]
Example data from server:
[code]
{
"aaData": [
{
"name": "Imperial Blue",
"name.package@v1": "Marketplace US"
},
{
"name": "Royal Blue",
"name.package@v1": "Marketplace US"
},
]
}
[/code]
I changed the behaviour of _fnGetObjectDataFn , _fnSetObjectDataFn methods to point to something other than '.' and it seems to work for me. May i know is there cleaner way to acheive this?
Related Code:
[code]
"aoColumns" : [
{"sTitle": "Name", "mData": "name"},
{"sTitle": "Package", "mData": "name.package@v1"},
....
]
[/code]
Example data from server:
[code]
{
"aaData": [
{
"name": "Imperial Blue",
"name.package@v1": "Marketplace US"
},
{
"name": "Royal Blue",
"name.package@v1": "Marketplace US"
},
]
}
[/code]
I changed the behaviour of _fnGetObjectDataFn , _fnSetObjectDataFn methods to point to something other than '.' and it seems to work for me. May i know is there cleaner way to acheive this?
This discussion has been closed.
Replies
Allan
I tried as suggested, but getting "Requested unknown parameter '1' from the data source for row 0" error.
Updated Code:
[code]
"aoColumns" : [
{"sTitle": "Name", "mData": "name"},
{"sTitle": "Package",
"mRender": function ( data, type, full ) {
return data['name.package@v1'];
}
}
....
]
[/code]
The output from the server is same as above. Am I missing something?
[code]
"aoColumns" : [
{"sTitle": "Name", "mData": "name"},
{"sTitle": "Package",
"sDefaultContent": "",
"mRender": function ( data, type, full ) {
return full['name.package@v1'];
}
}
....
]
[/code]
Allan