Creating table from Nested JSON Object

Creating table from Nested JSON Object

bluwabluwa Posts: 6Questions: 2Answers: 0
edited December 2021 in General

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

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    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

  • bluwabluwa Posts: 6Questions: 2Answers: 0

    Hmm, I understand I will try to do the same structure thanks colin :smile:

  • bluwabluwa Posts: 6Questions: 2Answers: 0
    edited December 2021

    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

  • bluwabluwa Posts: 6Questions: 2Answers: 0


    I can get arrays but in the columns section I couldn't access it.

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    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

Sign In or Register to comment.