0
我有一個嵌套視圖綁定到樹存儲。Sencha Touch 2:使用JSON數據填充Tree Store
如果我在商店內使用靜態數據,視圖會被填充此數據。
但是,如果我嘗試通過ajax代理(JSON)加載商店,則可以看到商店已獲取數據,但視圖不會填充此數據!
我一直堅持這個好幾天了。幫幫我 !上述
樹商店
Ext.define('MyApp.store.CategoriesNested', {
extend: 'Ext.data.TreeStore',
config: {
model: 'MyApp.model.CategoriesNested',
defaultRootProperty: 'data',
autoLoad: true,
autoSync: true,
data:[{
"category_id": 1,
"text": 'Clothing',
"data":[{
"category_id": 11,
"text": 'Tops and Tees',
"leaf":true,
}]
}, {
"category_id": 2,
"text": 'Footwear',
"data":[{
"category_id": 22,
"text": 'Casual Shoes',
"leaf":true,
},{
"category_id": 23,
"text": 'Sports Shirts',
"leaf":true,
}]
}],
}
});
工作正常。但是,如果我嘗試從JSON加載,這填充商店(檢查商店使用鉻網絡檢查器)。但是這個觀點並沒有反映出這一點!
Ext.define('MyApp.store.CategoriesNested', {
extend: 'Ext.data.TreeStore',
config: {
model: 'MyApp.model.CategoriesNested',
autoLoad: true,
autoSync: true,
proxy:{
type: 'ajax',
url:'categories.json',
reader:{
type: 'json',
rootProperty: 'data'
}
}
}
});
categories.json
{
"data": [{
"category_id": 1,
"text": 'Clothing',
"data":[{
"category_id": 11,
"text": 'Tops and Tees',
"leaf":true,
}]
}, {
"category_id": 2,
"text": 'Footwear',
"data":[{
"category_id": 22,
"text": 'Casual Shoes',
"leaf":true,
},{
"category_id": 23,
"text": 'Sports Shirts',
"leaf":true,
}]
}]
}
我到底做錯了什麼?
編輯
好吧,我意識到,如果這個嵌套列表直接設置在視口,然後它顯示的數據。
但是,目前的結構是這樣的:
視窗> Tab平板>導航視圖>面板>嵌套列表
同樣,nestedlist顯示數據時,我硬編碼存儲中的數據。但是當我從JSON讀取時,它不顯示數據。但是,如果我嘗試直接在視口上設置視圖,則會顯示數據!
爲什麼會發生這種情況?