打印版式

Class Ext.data.JsonReader

Package:Ext.data
Class:JsonReader
Extends:Ext.data.DataReader
Defined In:JsonReader.js
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.

The code below lists all configuration options.

var RecordDef = Ext.data.Record.create([
       {name: 'name', mapping: 'name'},     // "mapping" property not needed if it's the same as "name"
       {name: 'occupation'},                // This field will use "occupation" as the mapping.
   ]);
   var myReader = new Ext.data.JsonReader({
       totalProperty: "results",    // The property which contains the number of returned records (可选)
       root: "rows",                // The property which contains an Array of record objects
       id: "id"                     // The property within the record object that provides an ID for the record (可选)
   }, RecordDef);

This would consume a JSON file like this:


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

属性   -  方法   -  事件   -  设置选项

公共属性

属性 定义对象
  jsonData : Object JsonReader
After any data loads, the raw JSON data is available for further custom processing.

公共方法

方法 定义对象
  JsonReader(Object meta, Object[]/Ext.data.Record constructor}) JsonReader
Create a new JsonReader
  read(Object response) : Object JsonReader
This method is only used by a DataProxy which has retrieved data from a remote server.
  readRecords(Object o) : Object JsonReader
Create a data block containing Ext.data.Records from an XML document.

公共事件

此类没有公共事件。

设置选项

设置选项 定义对象
  id : String JsonReader
Name of the property within a row object that contains a record identifier value.
  root : String JsonReader
name of the property which contains the Array of row objects.
  successProperty : String JsonReader
Name of the property from which to retrieve the success attribute used by forms.
  totalProperty : String JsonReader
Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the wh...

属性详情

jsonData

public Object jsonData
After any data loads, the raw JSON data is available for further custom processing.
This property is defined by JsonReader.

构造函数

JsonReader

public function JsonReader(Object meta, Object[]/Ext.data.Record constructor})
Create a new JsonReader
参数:
  • meta : Object
    Metadata configuration options
  • constructor} : Object[]/Ext.data.Record
    recordType The record definition of the data record to produce.

方法详情

read

public function read(Object response)
This method is only used by a DataProxy which has retrieved data from a remote server.
参数:
  • response : Object
    The XHR object which contains the JSON data in its responseText.
返回:
  • Object
    data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.
This method is defined by JsonReader.

readRecords

public function readRecords(Object o)
Create a data block containing Ext.data.Records from an XML document.
参数:
  • o : Object
    An object which contains an Array of row objects in the property specified in the config as 'root, and optionally a property, specified in the config as 'totalProperty' which contains the total size of the dataset.
返回:
  • Object
    data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.
This method is defined by JsonReader.

设置详情

id

id : String
Name of the property within a row object that contains a record identifier value.
This config option is defined by JsonReader.

root

root : String
name of the property which contains the Array of row objects.
This config option is defined by JsonReader.

successProperty

successProperty : String
Name of the property from which to retrieve the success attribute used by forms.
This config option is defined by JsonReader.

totalProperty

totalProperty : String
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.
This config option is defined by JsonReader.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.