Creating table from Nested JSON Object
Creating table from Nested JSON Object
Hello all, I am trying to create a table from nested json object but I can't get access to objects I tried everything. Can you help me to figure it.
I am trying to create something like this,
and my code is like this;
http://live.datatables.net/lemesazi/1/edit
This question has an accepted answers - jump to answer
Answers
That data format won't work - as there's nothing to connect an order to a specific driver or cashier. This example here may help, it's showing nested data so could be something you could use as a template,
Colin
Hmm, I understand I will try to do the same structure thanks colin
I tried to change my json response similar to the example but I couldn't
so added driver, and cashier for orders.
Example is below.
http://live.datatables.net/qalebeva/1/edit
I can get arrays but in the columns section I couldn't access it.
Take a look at the Ajax docs for the supported data structures. I updated your last example to show how to display the orders:
http://live.datatables.net/qalebeva/2/edit
It looks like you want to associate drivers and cashiers to the orders. Not sure what your requirements for this are. Basically you need to use one array of data. Each element in the array can be a nested object or single level object. Datatables doesn't have a way to itereate over multiple arrays to apply the data.
How do you need to handle the drivers and cashiers?
Kevin