Prime React datatable nested JSON

UI Components for React
Post Reply
JaG
Posts: 3
Joined: 09 Jun 2020, 20:08

02 Sep 2020, 20:02

I would like to get some clarification on whether or not I can work with a nested JSON dataset in this format with the datatable.

Code: Select all

"name": "CategorizationTest",
  "collections": [
    {
      "name": "CollectionOne",
      "categories": [
        {
          "code": "001",
          "text": "Withdrawl"
        },

        {
          "code": "002",
          "text": "Point of sale purchase"
        },
        {
          "code": "003",
          "text": "Cardholder credit"
        },
        {
          "code": "004",
          "text": "Exchange Fee"
        }
      ],
      "mapDefinitions": [
        {
          "collectionName": "CollectionTwo",
          "required": true,
          "multiEntry": false,
          "alias": null
        },

        {
          "collectionName": "CollectionThree",
          "required": true,
          "multiEntry": true,
          "alias": "Third Collection"
        }
      ]
    }
I have read posts saying to flatten out this data and display it that way and others with the angular version saying I can just use map.name to get into the nested object. This doesn't work for me, so what is the best approach to displaying data from multiple layers of nesting in a react datatable?

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

10 Oct 2020, 23:03

Hi,

Sorry for the delayed response! I think this link can help to you;
https://www.primefaces.org/primereact/s ... /datatable

Please see;

Code: Select all

<Column sortField="country.name" filterField="country.name" header="Country" body={this.countryBodyTemplate} sortable filter filterMatchMode="contains" filterPlaceholder="Search by country"/>
<Column sortField="representative.name" filterField="representative.name" header="Representative" body={this.representativeBodyTemplate} sortable filter filterElement={representativeFilter} />
You can use field="collections.?.?.?" or set the cell output easily using body property.

Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests