Author Topic: How to set colModel's dataIndx to a nested JSON object?  (Read 3871 times)

qfinsoft

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
How to set colModel's dataIndx to a nested JSON object?
« on: May 26, 2015, 02:21:55 am »
I'm currently trying to bind a column to a nested JSON object within rowData's data.  (this also happens to be a detail-level grid column, but I don't think that matters)

Here is the desired colModel declaration for this particular 'altitude' column (note dataIndx in particular):

Code: [Select]
{ title: "Altitude", dataType: "string", width: 60, editable: false, sortable: false, dataIndx: "data.altitude"}
The above code doesn't display any data in the column.  That said, I can get the column to render the data using the code below, but doing it this way doesn't seem to allow column level sorting to work etc., so I'd like for dataIndx alone to be able to populate the altitude column without resorting to using a render function.

Code: [Select]
{ title: "Altitude", dataType: "string", width: 60, editable: false,
     render: function(ui) {
          return ui.rowData.data.altitude;
     }
},

Any suggestions?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: How to set colModel's dataIndx to a nested JSON object?
« Reply #1 on: May 26, 2015, 05:50:57 pm »
Nested JSON is not supported currently.

If you only need to support rendering and sorting, then you can implement render ( for custom rendering ) and sortType (for custom sorting).

http://jsfiddle.net/paramquery/ae3c4gtn/