Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.gwtext.client.data
Class JsonReader

    java.lang.Object
      com.gwtext.client.core.JsObject
          com.gwtext.client.data.Reader
              com.gwtext.client.data.JsonReader

    public class JsonReader

extends Reader

Data reader class to create an Array of Ext.data.Record objects from a JSON response based on mappings in a provided Ext.data.Record constructor.

Example code:

      RecordDef recordDef = new RecordDef(new FieldDef[]{
                 new StringFieldDef("name", "name"), // "mapping" property not needed if it's the same as "name"
                 new StringFieldDef("occupation")    // this field will use "occupation" as the mapping.
         });

      JsonReader reader = new JsonReader(new JsonReaderConfig() {
          {
              setTotalProperty("results"); // The property which contains the total dataset size (optional)
              setRoot("rows");             // The property which contains an Array of row objects
              setId("id");                 // The property within each row object that provides an ID for the record (optional)
          }}, recordDef);

This would consume a JSON file like this:

    { 'results': 2, 'rows': [
         { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
         { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
     }

Field Summary

Fields inherited from class com.gwtext.client.data.Reader
`configJS, recordDef`

Fields inherited from class com.gwtext.client.core.JsObject
`jsObj`

Constructor Summary
`JsonReader(RecordDef recordDef)` Constructs a new JsonReader.
`JsonReader(java.lang.String root, RecordDef recordDef)` Constructs a new JsonReader.

Method Summary
`protected com.google.gwt.core.client.JavaScriptObject` | `create(com.google.gwt.core.client.JavaScriptObject config, com.google.gwt.core.client.JavaScriptObject recordDef)`
`void` | `setId(java.lang.String id)` Name of the property within a row object that contains a record identifier value.
`void` | `setRoot(java.lang.String root)` Name of the property which contains the Array of row objects.
`void` | `setSuccessProperty(java.lang.String successProperty)` Name of the property from which to retrieve the success attribute used by forms.
`void` | `setTotalProperty(java.lang.String totalProperty)` Name of the property from which to retrieve the total number of records in the dataset.

Methods inherited from class com.gwtext.client.data.Reader
`getJsObj, getRecordDef, setRecordDef`

Methods inherited from class com.gwtext.client.core.JsObject
`getProperties, isCreated, setJsObj`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JsonReader

    public JsonReader(RecordDef recordDef)

  Constructs a new JsonReader.

  Parameters:
    `recordDef` - the record def

### JsonReader

    public JsonReader(java.lang.String root,
                      RecordDef recordDef)

  Constructs a new JsonReader.

  Parameters:
    `root` - the root property
    `recordDef` - the record def

Method Detail

### create

    protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config,
                                                                 com.google.gwt.core.client.JavaScriptObject recordDef)

  Overrides:
    `create` in class `Reader`

### setId

    public void setId(java.lang.String id)

  Name of the property within a row object that contains a record identifier value.

  Parameters:
    `id` - the id property

### setRoot

    public void setRoot(java.lang.String root)

  Name of the property which contains the Array of row objects.

  Parameters:
    `root` - the root property

### setSuccessProperty

    public void setSuccessProperty(java.lang.String successProperty)

  Name of the property from which to retrieve the success attribute used by forms.

  Parameters:
    `successProperty` - the success property

### setTotalProperty

    public void setTotalProperty(java.lang.String totalProperty)

  Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the whole dataset is not passed in one go, but is being paged from the remote server.

  Parameters:
    `totalProperty` - proeprty for total number of records

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD