What is the difference between data and dataMap and fields and fieldsMap

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Ok, so what is the difference between data & dataMap and fields&fieldsMap and when would you use them? They seem to be very similar.

Thank you
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
In a nutshell, the "map" version is just that, a Map (JavaScript object / associative array), rather than an ordered array / List.

data
is an ordered array of the rows in your Model, ordered by whatever "Order By" property you have set on your Model.
dataMap is a JavaScript object / Map of the rows in your Model, keyed by the row Id. We do NOT recommend that you inspect or modify dataMap directly, please use Model.getRowById(rowId) to find a row by it's Id.

fields is an ordered array of the Fields you requested for your Model, ordered by the order in which you added them to the Model.
fieldsMap is a JavaScript object / Map of the Fields you requested in your Model, keyed by the Field API Name. We do NOT recommend that you inspect or modify fieldsMap directly, please use Model.getField(fieldAPIName) to find Field metadata by a Field's API Name.

All of this is described in detail in the API docs for skuid.model.Model
Photo of Sofware Developer Guy

Sofware Developer Guy

  • 1,354 Points 1k badge 2x thumb
Thank you!