Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

tree - How to debug Extjs store url: path with firebug?

I am using the browser-layout example for my application.

I'm trying to add a tree grid to it. I defined a new class, but when I call my tree grid I can see the grid but no data inside.

What I'm trying to do is define the tree grid in a separate file. My main file is the layout-browser.js and I need to add this (and others) in the tabs I have in it. What might I be doing wrong?

here is my code:

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]

});

thank you for ur time and help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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 }]
        }
    ]
  }

Here is an working example, u can define myTree and call it in your Browser-layout!

ScreenShot



Go to firebug NET console, refresh the page and search for treeGrid.json, enter image description here

Hover over with mouse to see full URL
enter image description here
Update store with correct path from localstore to a folder with your .json

enter image description here
Try now!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...