2
我是Sencha Touch和網絡編程的新手。我試圖顯示一個嵌套列表,並且只是一次又一次地獲取循環中的第一級項目。我已經看過文檔和廚房水槽的例子,但我無法正確理解它。我會非常感謝提示!嵌套列表與Sencha Touch無限循環1
這是我的代碼:
Ext.regModel('Site', {
fields: [
{name: "sitename", type: "string"},
{name: "last_connection", type: 'auto'},
]
});
Ext.setup({
icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function(){
var store = new Ext.data.TreeStore({
model: 'Site',
proxy: {
type: 'ajax',
url: 'network.json',
reader: {
type: 'json',
root: 'items'
}
}
});
var nestedList = new Ext.NestedList({
fullscreen: true,
title: 'Netzwerk',
displayField: 'sitename',
plugins: [new Ext.LeafSelectedPlugin()],
// add a/for folder nodes in title/back button
getTitleTextTpl: function() {
return '{' + this.displayField + '}<tpl if="leaf !== true">/</tpl>';
},
// add a/for folder nodes in the list
getItemTextTpl: function() {
return '{' + this.displayField + '}<tpl if="leaf !== true">/</tpl>';
},
store: store
});
}
});
而且JSON文件的結構(只有一個節點爲例):
{"items": [{
"id":"11",
"sitename":"Site A",
"items":[
{
"id":"11",
"sitename":"Endpoint 1",
"last_connection":"2012-03-02T10:03:22+0100",
"ping_time":63,
"leaf": true
},
{
"id":"12",
"sitename":"Endpoint 2",
"last_connection":"2012-03-02T10:03:22+0100",
"ping_time":57,
"leaf": true
}],
"last_connection":"2012-03-02T10:03:22+0100",
"ping_time":57
}]}
謝謝!