使用Sencha Touch 2.3
型号:
Ext.define("MyModel", {
extend: "Ext.data.Model",
fields: [
{name: 'id'},
{name: 'test', type: 'string'},
]
});
商店:
Ext.define('MyStore', {
extend: 'Ext.data.Store',
model: 'MyModel',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'd.php',
reader: {
type: 'json',
rootProperty: 'data',
totalProperty : 'totalNumber',
idProperty: 'id'
}
},
});
列表:
{
itemId: 'histTab',
iconCls: 'favorites',
xtype: 'list',
flex:1,
itemTpl: ['{id} / {test}'],
store: mystore
},
数据:
[{
"success": true,
"data": \[
{ "id": "1", "test": "test 1" },
{ "id": "2", "test": "test 2"},
{ "id": "3", "test": "test 3" }
\]
}]
输出:
为什么test
字段未显示?
答案 0 :(得分:1)
试试这个......
的MyStore -
Ext.define('test.store.MyStore', {
extend: 'Ext.data.Store',
model: 'test.model.MyModel',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data.json',
id: 'MyStore',
storeId:'MyStore',
reader: {
type: 'json',
rootProperty: 'data',
totalProperty : 'totalNumber',
idProperty: 'id'
}
},
});
列表 -
{
itemId : 'histTab',
iconCls : 'favorites',
xtype : 'list',
height: 200,
flex : 1,
itemTpl : ['{id} / {test}'],
store : 'MyStore'
}
JSON -
{
"success":true,
"data": [
{ "id": "1", "test": "test 1" },
{ "id": "2", "test": "test 2"},
{ "id": "3", "test": "test 3" }
]
}