A ListGridRecord is a JavaScript Object whose properties contain values for each
{@link com.smartgwt.client.widgets.grid.ListGridField}. A ListGridRecord may have additional properties which affect the
record's appearance or behavior, or which hold data for use by custom logic or other,
related components.
For example a ListGrid that defines the following fields:
fields : [
{name: "field1"},
{name: "field2"}
],
Might have the following data:
data : [
{field1: "foo", field2: "bar", customProperty:5},
{field1: "field1 value", field2: "field2 value", enabled:false}
]
Each line of code in the
data
array above creates one JavaScript Object via
JavaScript {type:ObjectLiteral,object literal} notation. These JavaScript Objects are
used as ListGridRecords.
Both records shown above have properties whose names match the name property of a
ListGridField, as well as additional properties. The second record will be disabled due to
enabled:false
; the first record has a property "customProperty" which will
have no effect by default but which may be accessed by custom logic.
After a ListGrid is created and has loaded data, records may be accessed via
{@link com.smartgwt.client.widgets.grid.ListGrid#getData data}, for example, listGrid.data.get(0) retrieves the first record.
ListGridRecords are also passed to many events, such as
{@link com.smartgwt.client.widgets.grid.ListGrid#addCellClickHandler cellClick()}.
A ListGridRecord is always an ordinary JavaScript Object regardless of how the grid's
dataset is loaded (static data, java server, XML web service, etc), and so supports the
normal behaviors of JavaScript Objects, including accessing and assigning to properties
via dot notation:
var fieldValue = record.fieldName;
record.fieldName = newValue;
Note however that simply assigning a value to a record won't cause the display to be
automatically refreshed - {@link com.smartgwt.client.widgets.grid.ListGrid#refreshCell ListGrid.refreshCell} needs to be called. Also,
consider{@link com.smartgwt.client.docs.Editing editValues vs saved values} when directly modifying
ListGridRecords.
See the attributes in the API tab for the full list of special properties on
ListGridRecords that will affect the grid's behavior.
@see com.smartgwt.client.widgets.grid.ListGrid#getData