Author Topic: JSON Data with Child Objects  (Read 4889 times)

jax

  • Newbie
  • *
  • Posts: 16
    • View Profile
JSON Data with Child Objects
« on: June 23, 2014, 07:22:20 am »
I have JSON being returned to the grid and the top level JSON object is binding correctly. However, if I try to bind to the Child object properties it does not work . For example, the Facility.Name is not being set, but the last and first names are. If I write data[0].Facility.Name to the console I am able to see the child object property so I know the data is there and valid. How is this handled with param query?

        var colM = [
            { title: 'Last Name', width: 100, dataIndx: 'LastName', dataType: 'string' },
            { title: 'First Name', width: 100, dataIndx: 'FirstName', dataType: 'string' },
            { title: 'Facility', width: 100, dataIndx: "Facility.Name", dataType: 'string' },
        ];

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5791
    • View Profile
Re: JSON Data with Child Objects
« Reply #1 on: June 23, 2014, 08:38:44 am »
you could use column.render callback function for that.

render: function(ui){
  return ui.rowData['Facility']['Name'];
}

jax

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: JSON Data with Child Objects
« Reply #2 on: June 23, 2014, 08:46:59 am »
Thanks that works :)