How to debug Extjs store url: path with firebug?

2019-01-20 16:03发布

问题:

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

回答1:

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!



Go to firebug NET console, refresh the page and search for treeGrid.json,

Hover over with mouse to see full URL

Update store with correct path from localstore to a folder with your .json


Try now!