Ext.data.JsonReader を使用して Ext.data.JsonStore モデルをマッピングしているときに、sencha で問題に直面しています。
サーバーからの Json 応答 (サーバー モデル):
{"rows":[{"id":1,"firstname":"Bill"},{"id": 2,"firstname":"Ben"}]}
Json ストアで使用されるモデル:
Ext.regModel( 'mycabinet', {
fields: [
{ name : 'DeviceId', type: 'int' },
'CabinetName']
});
json リーダー コード:
var iccDeviceReader = new Ext.data.JsonReader({
// metadata configuration options:
idProperty: 'id',
root: 'rows',
fields: [
{name: 'CabinetName', mapping: 'firstname'},
{name:'DeviceId',mapping:'id'}
]
});
json ストア コード:
app.iccDS = new Ext.data.JsonStore( {
model : 'mycabinet',
sorters : 'CabinetName',
getGroupString : function(record) { return record.get('CabinetName')[0]; },
proxy : {
type: 'ajax',
url : '/icc/js/data.js',
reader:iccDeviceReader
},
autoLoad: true
} );
「mycabinet」モデルに「サーバー モデル」が追加されることを期待しています。ただし、マッピングは行われません。成功せずに convert を使用してみました(name:'DeviceId',mapping:'id',convert: function(v){return v.id;})
どんな助けでも大歓迎です。ありがとう