JSON data that does not have aaData node
JSON data that does not have aaData node
PaoloValladolid
Posts: 35Questions: 0Answers: 0
I am using Datatables 1.6. The JSON data I am working with was generated by Java/Spring 3.x. Spring 3.x has built in capability to transform Java objects into JSON. In the JSON example below, the JSON was generated from 3 Java objects:
[
{"description":"Contamination (soil or product)","code":"C","isActive":"Y"},
{"description":"Domestic Animal (pre 1998 reg or undetermined)","code":"D","isActive":"Y"},
{"description":"Domestic Animal - Fatality","code":"DA","isActive":"Y"}
]
Note there is no aaData node. I figured out how to hack around the lack of an aaData so that I can display the above in Datatables. However, is there some Datatables 1.6 or Datatables 1.7 functionality that I overlooked that can parse JSON data like the above into an aaData array?
[
{"description":"Contamination (soil or product)","code":"C","isActive":"Y"},
{"description":"Domestic Animal (pre 1998 reg or undetermined)","code":"D","isActive":"Y"},
{"description":"Domestic Animal - Fatality","code":"DA","isActive":"Y"}
]
Note there is no aaData node. I figured out how to hack around the lack of an aaData so that I can display the above in Datatables. However, is there some Datatables 1.6 or Datatables 1.7 functionality that I overlooked that can parse JSON data like the above into an aaData array?
This discussion has been closed.
Replies
Here is an example of how it can be done for the OpenSearch format http://datatables.net/plug-ins/server-data-formats . Your own plug-in can be much simpler - just a couple of lines will do it.
Allan
Can you post your hack for not needing the aaData?
[code]
_fnAddData( oSettings, json.aaData[i] );
[/code]
that defines the property used for Ajax source (there are a few other instances of aaData, depending on your data source - server-side processing for example). I'm thinking about making this configurable in 1.8.
Allan
For instance:
[code]
{"aaData":[{"custID":999,"code":"CA","isActive":"Y", "orders":[{orderID:22,amount:44,productID:443},{orderID:66,amount:90,productID:567}]},
{"custID":123,"code":"DA","isActive":"Y", "orders":[{orderID:1,amount:50,productID:123},{orderID:45,amount:10,productID:456}]}
]}
[/code]
Regards,
Allan
Regards,
Allan
Any feedback on the new feature is welcome!
Regards,
Allan