2015-04-15 21 views
0

Hy, 我通过ExtJs Rest Proxy发送数据时遇到问题。当我POST数据我得到的异常ExtJS:其余代理发布数据失败

在Chrome

:遗漏的类型错误:在Firefox中无法读取的不确定

财产 'clientIdProperty':类型错误:clientRecords [0]未定义

我的商店

Ext.define('Test.store.Test', { 
extend: 'Ext.data.Store', 

requires: [ 
    'Test.model.test', 
    'Ext.data.proxy.Rest', 
    'Ext.data.reader.Json' 
], 

constructor: function(cfg) { 
    var me = this; 
    cfg = cfg || {}; 
    me.callParent([Ext.apply({ 
     storeId: 'Test', 
     model: 'Test.model.test', 
     proxy: { 
      type: 'rest', 
      url: '/resources/php/test.php', 
      reader: { 
       type: 'json' 
      } 
     } 
    }, cfg)]); 
} 

我的模型

Ext.define('Test.model.test', { 
extend: 'Ext.data.Model', 

requires: [ 
    'Ext.data.field.Field' 
], 

fields: [ 
    { 
     name: 'Test' 
    } 
] 

有没有一个标准ANS从服务器?

我希望有人能帮助我 THX的帮助

+0

分配root属性为你的读者 – Yellen

回答

0

在你的读者的配置,提供了一个“根”属性。

在内线4.x中它就会像

reader: { 
     type: 'json', 
     root: 'root' 
    } 

而且Ext 5.x中,这将是

reader: { 
     type: 'json', 
     rootProperty: 'root' 
    } 

这里就是API医生说 -

rootProperty : String The name of the property which contains the data items corresponding to the Model(s) for which this Reader is configured. For JSON reader it's a property name (or a dot-separated list of property names if the root is nested). For XML reader it's a CSS selector. For Array reader the root is not applicable since the data is assumed to be a single-level array of arrays.

By default the natural root of the data will be used: the root JSON array, the root XML element, or the array.

The data packet value for this property should be an empty array to clear the data or show no data.

Defaults to: ''

例如,如果来自服务器的JSON响应是

{ 
    "data": { 
    "Test": "TEST" 
    }, 
    "someOtherField": "Some Value" 
} 

然后,你rootProperty /根将成为 -

rootProperty: 'data' 

- 由于数据对应于模型