How to Bind to an Associative Object
How to Bind to an Associative Object
AdrianSmithUK
Posts: 26Questions: 10Answers: 0
Hi
http://jsfiddle.net/AdrianSmithUK/xkk4a7qc/4/
In the fiddle above there are two examples.
Example 1 is fine and the dataset looks like this:
var dataSet1 = [
{"name":"jim", "age":3, "next":4},
{"name": "bill", "age": 5, "next": 6}
];
Unfortunately I cant get Example 2 to work:
var dataSet2 = {
"jim": {"age": 3, "next": 4},
"bill": {"age": 5, "next": 6}
};
Is this possible?
Kind Regards,
Adrian Smith
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
No - DataTables requires the data to be given in an array at the top level. The data source for each row can be either, but for the data set as a whole it must be an array.
You would need to convert the object to an array.
Allan
Many Thanks Allan
Robert Schutt of Experts Exchange proposed a conversion function:
It's posted here in case anybody else has the same problem.
http://jsfiddle.net/AdrianSmithUK/xkk4a7qc/6/
Kind Regards,
Adrian