2015-04-15 2 views
0

Hy, У меня проблема, отправив данные через прокси-сервер ExtJs Rest. Когда я POST данных я получаю исключениеExtJS: Отказ данных после прокси-сервера

в Chrome: неперехваченным TypeError: Не удается прочитать свойство 'clientIdProperty' неопределенной

в Firefox: TypeError: 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)]); 
} 

My Model

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

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

fields: [ 
    { 
     name: 'Test' 
    } 
] 

есть стандартный анс от сервера?

Я надеюсь, что кто-то может помочь мне Thx для справки

+0

Назначьте корневое свойство для вашего читателя – 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' 

- Так как данные соответствуют вашей модели

Смежные вопросы