2011-06-13 70 views
1

我正在爲我的應用程序使用browser-layout示例。我想向它添加tree grid。我定義了一個新類,但是當我打電話給我的樹形網格時,我可以看到網格,但沒有數據。如何調試Extjs商店網址:用螢火蟲路徑?

我想要做的是在一個單獨的文件中定義樹網格。我的主要文件是layout-browser.js,我需要在我擁有的選項卡中添加此(和其他)。我可能會做錯什麼?

這裏是我的代碼:

Ext.require([ 
'Ext.data.*', 
'Ext.grid.*', 
'Ext.tree.*' 
]); 

Ext.define('Task', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { name: 'task', type: 'string' }, 
     { name: 'user', type: 'string' }, 
     { name: 'duration', type: 'string' } 
    ] 
}); 

var store = Ext.create('Ext.data.TreeStore', { 
    model: 'Task', 
    proxy: { 
     type: 'ajax', 
     //the store will get the content from the .json file 
     url: 'treegrid.json' 
    }, 

    folderSort: true 
}); 



var tree = new Ext.tree.Panel({ 
title: 'Core Team Projects', 
store : store, 

columns:[ 
{ 
    header: 'Task', 
    dataIndex: 'task', 
    width: 80 
},{ 
    header: 'Duration', 
    width: 80, 
    dataIndex: 'duration', 
    //align: 'center', 
    //sortType: 'asFloat' 

},{ 
    header: 'Assigned To', 
    width: 80, 
    dataIndex: 'user' 
}] 
}); 


Ext.define("Ext.app.myTreeGrid", { 
    extend: "Ext.panel.Panel", 


width: 300, 
height : 300, 
items: [tree] 

}); 

感謝您對烏爾時間,並幫助

+0

任何想法? – Armance 2011-06-13 09:50:29

+0

把每個DEFINE代碼塊放在一個單獨的文件中,並使用loader來加載它,執行文件CREATE,VAR ...放在一個單獨的文件中,而不是一個定義文件,然後當你檢查所有的東西加載時試試調試!你的讀者也在哪裏!你需要一棵樹。 – 2011-06-13 10:20:27

+0

我一直這樣做,但它對我來說太多的文件,即使我把兩個文件放在同一個文件中,它也可以運行,例如 – Armance 2011-06-13 10:34:15

回答

3
var store = Ext.create('Ext.data.TreeStore', { 
proxy:{ 
    type: 'ajax', 
    url: 'myTree.json', 
}, 
reader:{ 
    type: 'ajax', 
    root: 'nodes', 
    record: 'leaf' 
} 
}); 


var myTree = Ext.create('Ext.tree.Panel', { 
    store: store, 
    rootVisible: false, 
    border: false, 
    renderTo:Ext.getBody() //missing 

}); 

JSON 

    { 

    children: [ 
     { text:"Clients", expanded: true, 
      children: [{ text:"MAIN", leaf: true }] 
     } 
    ] 
    } 

這裏是一個工作示例,U可以定義myTree並把它在你的瀏覽器的佈局!

ScreenShot



轉到Firebug的NET控制檯,刷新頁面並搜索treeGrid.json, enter image description here

將鼠標懸停在鼠標,查看完整的URL
enter image description here
更新使用.json存儲從localstore到文件夾的正確路徑

enter image description here
立即試用!

+0

非常感謝,我做了一些修改,並改變了我的問題。很好看一看 – Armance 2011-06-13 10:38:26

+0

我增加讀者它dosnt改變任何東西,加上即時通訊嘗試建立一個treegrid,但你的例子是一個簡單的樹嗎? – Armance 2011-06-13 10:45:28

+0

你看到treegrid.json成功加載到firebug中嗎? – 2011-06-13 11:53:45