|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gwtext.client.core.JsObject
com.gwtext.client.data.Reader
com.gwtext.client.data.JsonReader
public class JsonReader
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 |
---|
public JsonReader(RecordDef recordDef)
recordDef
- the record defpublic JsonReader(java.lang.String root, RecordDef recordDef)
root
- the root propertyrecordDef
- the record defMethod Detail |
---|
protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config, com.google.gwt.core.client.JavaScriptObject recordDef)
create
in class Reader
public void setId(java.lang.String id)
id
- the id propertypublic void setRoot(java.lang.String root)
root
- the root propertypublic void setSuccessProperty(java.lang.String successProperty)
successProperty
- the success propertypublic void setTotalProperty(java.lang.String totalProperty)
totalProperty
- proeprty for total number of records
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |