Package com.smartgwt.client.data

# Class Record

java.lang.Object
com.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.core.RefDataClass
com.smartgwt.client.data.Record

All Implemented Interfaces:
  `HasHandlers`

Direct Known Subclasses:
  `CalendarEvent`, `DetailViewerRecord`, `ListGridRecord`

public class Record extends RefDataClass
A Record contains attributes that are displayed and edited by a `DataBoundComponent`.

DataBoundComponents have a concept of named fields, where values for each field are found under the same-named attribute in a Record.

The concept of working with Records is common to all DataBoundComponents, although individual DataBoundComponents may work with singular records (`DynamicForm`) or may work with lists (`ListGrid`), trees (`TreeGrid`), or cubes (CubeGrid) of records.

A Record is always the same type of Java object regardless of how the record is loaded (static data, java server, XML web service, etc). However, individual DataBoundComponents may also look for special attributes on Records which control styling or behavior. For convenience, there are subclasses of Record with type-safe setters for such attributes (such as `ListGrid.setRecordEditProperty(String)`). In reality, all such subclasses are wrappers over the same underlying data object, and you can convert to whichever wrapper is most convenient via:

        new ListGridRecord(recordInstance.getJsObj());

You can also create your own subclass of Record with type-specific getters and setters, however, if you do so, you should store values via setAttribute() and retrieve them via getAttribute() rather than keeping values as normal Java properties. Only attributes will be visible to DataBoundComponents, ordinary Java properties will not.

Note that directly changing an attribute of a Record via setAttribute() will not notify any DataBoundComponents that the Record has changed or cause any kind of persistence operation to occur. Instead, use component-specific methods such as DynamicForm.setValue() or ListGrid.setEditValue() to explicitly tell the components about a change that should be saved.

- ## Field Summary

  ### Fields inherited from class com.smartgwt.client.core.RefDataClass

  `id`

  ### Fields inherited from class com.smartgwt.client.core.DataClass

  `factoryCreated, factoryProperties`

  ### Fields inherited from class com.smartgwt.client.core.JsObject

  `jsObj`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Record()`
  `Record(JavaScriptObject jsObj)`
  `Record(Map recordProperties)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Record[]`
  `convertToRecordArray(JavaScriptObject nativeArray)`
  `static Record`
  `copyAttributes(Record record, String... properties)`
  Creates a shallow copy of `record` containing its attributes for properties named in `properties`.
  `static void`
  `copyAttributesInto(Record destRecord, Record record, String... properties)`
  Shallow copies the attributes of `record` to `destRecord` for properties named in `properties`.
  `Record[]`
  `getAttributeAsRecordArray(String property)`
  Returns the nested structure as Record array.
  `RecordList`
  `getAttributeAsRecordList(String property)`
  Returns the nested structure as a RecordList.
  `static Record`
  `getOrCreateRef(JavaScriptObject jsObj)`
  `Map`
  `getPaletteDefaults()`
  This method returns a Map of config properties suitable for use as the "defaults" attribute of a `PaletteNode`.
  `static boolean`
  `isARecord(Object obj)`
  `Map`
  `toMap()`
  Convert this record to a Map.

  ### Methods inherited from class com.smartgwt.client.core.RefDataClass

  `getRef, getRef, internalSetID`

  ### Methods inherited from class com.smartgwt.client.core.DataClass

  `applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated`

  ### Methods inherited from class com.smartgwt.client.core.JsObject

  `equals, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObj`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Record

    public Record()

  - ### Record

    public Record(JavaScriptObject jsObj)

  - ### Record

    public Record(Map recordProperties)

- ## Method Details

  - ### isARecord

    public static boolean isARecord(Object obj)

  - ### copyAttributes

    public static Record copyAttributes(Record record, String... properties)
    Creates a shallow copy of `record` containing its attributes for properties named in `properties`.
    Parameters:
      `record` - the record to copy attributes from.
      `properties` - an array of properties to copy.
    Returns:
      a copy of `record` containing only the attributes for properties named in `properties`.

  - ### copyAttributesInto

    public static void copyAttributesInto(Record destRecord, Record record, String... properties)
    Shallow copies the attributes of `record` to `destRecord` for properties named in `properties`.
    Parameters:
      `destRecord` - (out) destination record into which attributes are copied.
      `record` - the record to copy attributes from.
      `properties` - an array of properties to copy.

  - ### getOrCreateRef

    public static Record getOrCreateRef(JavaScriptObject jsObj)

  - ### getPaletteDefaults

    public Map getPaletteDefaults()
    This method returns a Map of config properties suitable for use as the "defaults" attribute of a `PaletteNode`. Use it when you need to work with PaletteNodes indirectly, such when setting up `TileRecord`s that will be used in a `TilePalette`. See `the dev tools overview` for examples of how to assemble and acquire a suitable defaults object when you are creating a PaletteNode indirectly

  - ### getAttributeAsRecordArray

    public Record[] getAttributeAsRecordArray(String property)
    Returns the nested structure as Record array.
    Parameters:
      `property` - the record property
    Returns:
      array of records

  - ### getAttributeAsRecordList

    public RecordList getAttributeAsRecordList(String property)
    Returns the nested structure as a RecordList.
    Parameters:
      `property` - the record property
    Returns:
      the RecordList

  - ### convertToRecordArray

    public static Record[] convertToRecordArray(JavaScriptObject nativeArray)

  - ### toMap

    public Map toMap()
    Convert this record to a Map. This is a recursive conversion so if an attribute on this record is set to another Record instance it will also be converted to a Map.
    Returns:
      the Map