Datatable - nested array of json object

jQuery UI Widgets
Post Reply
Cafeinoman
Posts: 3
Joined: 19 Sep 2014, 09:29

08 Dec 2016, 19:35

Hi,

I wish to know how I can display data with nested array of json objects. for example :

Code: Select all

{
  "name":"foo",
  "relations":[
    {"label":"label1",
      "to":{"name":"baz1"}},
    {"label":"label2",
      "to"::{"name":"baz2"}},
    {"label":"label3",
      "to"::{"name":"baz3"}}
  ]
}
I wish to display, on each row, the main name and the nested object's name. Can I use, at least, "relations[0].to.name" as field value to display the first instance? Can I use group method to simulate a subtable? (I don't see how...)

Thanks in advance.

rok7
Posts: 10
Joined: 02 Mar 2016, 15:48

13 Jan 2017, 15:59

Serach this forum for 'datatable columns from a non-flattened source' for a possible solution.

For deeper nested sources I use 'dotize' (https://www.npmjs.com/package/dotize) to flatten the array first. After this step you can use the normal 'dot' notation:

Code: Select all

{ field: 'device.name', headerText: 'Name' },
The second approach has the advantage that on datables the 'sortable' and 'filter' options will work.

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests