user2885131
user2885131

Reputation: 13

ExtJs- TreeStore AJAX Proxy not sending request to Server or TreeStore is not loading

Ext js TreeStore is not loading

Ext.ns('App');

Ext.onReady(function() {
  Ext.QuickTips.init();
  App.PPPExplorer.init(); 
});


App.PPPExplorer = {

// Initialize application
init : function(serverCfg) {        
    this.PPP = this.createPPP();
},

createPPP : function() {


// Set up a model to use in our Store
Ext.define('Summary', {
  extend: 'Ext.data.Model',
  fields: [
     {name: 'pid', type: 'string'}
  ]
});

var myStore = Ext.create('Ext.data.TreeStore', {
 model: 'Summary',
 storeId:'myStore',
 proxy: {
     type : 'ajax',
     method: 'GET',
     url: '/Explorer.do?method=getPPP&search=true',
     reader: {
         type: 'json'
     },
     root: {
         pid: 'src',
         text:'test',
         expanded: true
     },
 },
 autoLoad: true
 });

Ext.create('Ext.tree.Panel', {
    title: 'Simple Tree',
    width: 200,
    height: 150,
    store: myStore,
//      rootVisible: true,
    renderTo: 'Explorer',


        columns: [{
             xtype: 'treecolumn', //this is so we know which column will show the tree
             text: 'Reference',
             flex: 2,
             sortable: true,
             dataIndex: 'pid',
             locked: true
        }]
});


  }
}

I am using Ext js 4.2 Version

I have used treeStore, treePanel in the above code, somehow Proxy call is not sent to Server. There was no error message in the console

Thanks in advance

Upvotes: 1

Views: 2774

Answers (1)

overlordhammer
overlordhammer

Reputation: 1333

Root definition should be inside TreeStore definition as follows (it's on the proxy declaration now):

var myStore = Ext.create('Ext.data.TreeStore', {
model: 'Summary',
storeId: 'myStore',
proxy: {
    type: 'ajax',
    method: 'GET',
    url: '/Explorer.do?method=getPPP&search=true',
    reader: {
        type: 'json'
    }
},
autoLoad: true,
root: {
    pid: 'src',
    text: 'test',
    expanded: true
}

});

That way your code works, you can see it here

Upvotes: 3

Related Questions