DT_RowId and RowClass
DT_RowId and RowClass
genial
Posts: 9Questions: 0Answers: 0
HI ,
I could able to generated json with DT_RowId and DT_RowClass, but datatables is not able to parse it.
This the generated code from the server (json)
[code]
{"0": "Gecko",
"1": "Firefox 1.0",
"2": "Win 98+ / OSX.2+",
"3": "1.7",
"4": "A",
"DT_RowId": "row",
"DT_RowClass": "Class"
},
{"0": "Gecko",
"1": "Firefox 1.5",
"2": "Win 98+ / OSX.2+",
"3": "1.8",
"4": "A"
,"DT_RowId": "row",
"DT_RowClass": "Class"
}
[/code]
Thank you,
I could able to generated json with DT_RowId and DT_RowClass, but datatables is not able to parse it.
This the generated code from the server (json)
[code]
{"0": "Gecko",
"1": "Firefox 1.0",
"2": "Win 98+ / OSX.2+",
"3": "1.7",
"4": "A",
"DT_RowId": "row",
"DT_RowClass": "Class"
},
{"0": "Gecko",
"1": "Firefox 1.5",
"2": "Win 98+ / OSX.2+",
"3": "1.8",
"4": "A"
,"DT_RowId": "row",
"DT_RowClass": "Class"
}
[/code]
Thank you,
This discussion has been closed.
Replies
DataTables requires that the data above be put into a variable inside a master object. the variable is traditionally named aaData (you can change this by specifying an alternate sAjaxDataProp . see http://www.datatables.net/ref#sAjaxDataProp)
also your aaData should be an array of arrays, or array of objects. note the square brackets used below "[" and "]"
[code]
{
"aaData": [
{"0": "Gecko",
"1": "Firefox 1.0",
"2": "Win 98+ / OSX.2+",
"3": "1.7",
"4": "A",
"DT_RowId": "row",
"DT_RowClass": "Class"
},
{"0": "Gecko",
"1": "Firefox 1.5",
"2": "Win 98+ / OSX.2+",
"3": "1.8",
"4": "A"
,"DT_RowId": "row",
"DT_RowClass": "Class"
}]
}
[/code]
in the AJAX/JSON example http://www.datatables.net/release-datatables/examples/data_sources/ajax.html
here is the JSON used: http://www.datatables.net/release-datatables/examples/ajax/sources/arrays.txt
i am getting the same problem.
Current problem is datatable have not parsed array of objects but it parses array of arrays correctly,
My working json code:
[code]
{"sEcho":1,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[["Residential","Residential Card1","Active"],["Vehicle","Vehicle Scoring Card","Passive"],["Personal","Personal Scoring Card","Passive"]]}
[/code]
in this example my json code is array of arrays and it works quite well. But the thing is i can not set DT_RowId and DT_RowClass properties to an array. Instead i need to use an object.
And not working example datatables gives "DataTables warning (table id = 'tblScoringList'): Requested unknown parameter '0' from the data source for row 0" error. Here is my json code:
[code]
{"sEcho":1,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[{"Loan":"Residential","Name":"Residential Card1","Status":"Active"},{"Loan":"Vehicle","Name":"Vehicle Scoring Card","Status":"Passive"},{"Loan":"Personal","Name":"Personal Scoring Card","Status":"Passive"}]}
[/code]
in this example my json code is array of objects and i think the problem is in here.
http://www.datatables.net/ref#mDataProp
http://www.datatables.net/blog/Extended_data_source_options_with_DataTables
http://www.datatables.net/usage/server-side