PDA

View Full Version : Extjs 7.2.0 TreeStore not reaching out to url



harrypottar
18 Aug 2020, 6:42 AM
I have been using Extjs since version 4 using MVC, trying MVVC and at a loss with my treestore.

I'm watch the access log and the store does not call out, when I dump the store to the console it states type is memory although I set to ajax.

I have tried for about 3 days to figure this out with no look

Sorry looks like pasting code lost all formatting



Ext.define('sassbackup.store.Category', {
extend: 'Ext.data.TreeStore',
storeId: 'category',
alias: 'store.category',
requires: 'sassbackup.model.Category',
model: 'sassbackup.model.Category',

buffered: false,
autoLoad: false,
remoteFilter: false,
remoteSort: false,
autoSync: false,
proxy: {
type: 'ajax',
url: '/modules/BACKUP.php',
reader: {
type: 'json',
root: 'root'
},
actionMethods: {
create : 'POST',
read : 'POST',
update : 'POST',
destroy: 'POST'
},
extraParams: { action: 'fetchPaths'}
}
});




Ext.define('sassbackup.view.main.MainController', {
extend: 'Ext.app.ViewController',


alias: 'controller.main',
requires: [
'sassbackup.store.Category'
],
config: {
stores:['sassbackup.store.Category']
},


onItemSelected: function (sender, record) {
Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},


onTabChange: function(tabPanel, newTab, oldTab, index) {
console.log(tabPanel);
console.log(newTab);
console.log(oldTab);
console.log(index);
if (newTab.title == "Categories") {
var categoryStore = Ext.getStore('category');
console.log(categoryStore);
categoryStore.load({
params: {
instanceId: '2',
action: 'fetchPaths'
},
scope : this,
callback: function (records, operation, success) {
console.log(records);
console.log(operation);
console.log(success);
console.log(operation.response.responseText);
}
});
}
},


onConfirm: function (choice) {
if (choice === 'yes') {
//
}
}
});




Ext.define('sassbackup.view.main.CategoryView', {
extend: 'Ext.tree.Panel',
xtype: 'categorytree',


requires: [
'sassbackup.store.Category'
],
title: 'Category',
height: 200,
width: 300,
rootVisible: false,
useArrows: true,
lines: false,
store: {
type: 'category'
}
});




Ext.define('sassbackup.view.main.Main', {
extend: 'Ext.tab.Panel',
xtype: 'app-main',


requires: [
'Ext.plugin.Viewport',
'Ext.window.MessageBox',
'Ext.tree.Panel',
'sassbackup.view.main.MainController',
'sassbackup.view.main.MainModel',
'sassbackup.view.main.List',
'sassbackup.view.main.CategoryView',
'sassbackup.store.Category'
],
stores:['sassbackup.store.Category'],
controller: 'main',
viewModel: 'main',


ui: 'navigation',


tabBarHeaderPosition: 1,
titleRotation: 0,
tabRotation: 0,


header: {
layout: {
align: 'stretchmax'
},
title: {
bind: {
text: '{name}'
},
flex: 0
},
iconCls: 'fa-th-list'
},


tabBar: {
flex: 1,
layout: {
align: 'stretch',
overflowHandler: 'none'
}
},


responsiveConfig: {
tall: {
headerPosition: 'top'
},
wide: {
headerPosition: 'left'
}
},


defaults: {
bodyPadding: 20,
tabConfig: {
responsiveConfig: {
wide: {
iconAlign: 'left',
textAlign: 'left'
},
tall: {
iconAlign: 'top',
textAlign: 'center',
width: 120
}
}
}
},
listeners: {
tabchange: 'onTabChange'
},
items: [{
title: 'Home',
iconCls: 'fa-home',
// The following grid shares a store with the classic version's grid as well!
items: [{
xtype: 'mainlist'
}]
}, {
title: 'Users',
iconCls: 'fa-user',
bind: {
html: '{loremIpsum}'
}
}, {
title: 'Categories',
iconCls: 'fa-users',
xtype: 'categorytree'
}, {
title: 'Settings',
iconCls: 'fa-cog',
bind: {
html: '{loremIpsum}'
}
}]
});



58225


Thanks
Harry

harrypottar
18 Aug 2020, 11:19 AM
I got a little further in debugging this.

In the view controller when I get the store I can set the proxy and it works, is the exact same proxy that is defined in the treestore but is some how lost.



Ext.define('sassbackup.view.main.MainController', {
extend: 'Ext.app.ViewController',


alias: 'controller.main',
requires: [
'sassbackup.store.Category'
],
config: {
stores:['sassbackup.store.Category']
},


onItemSelected: function (sender, record) {
Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},


onTabChange: function(tabPanel, newTab, oldTab, index) {
console.log(tabPanel);
console.log(newTab);
console.log(oldTab);
console.log(index);
if (newTab.title == "Categories") {
var categoryStore = Ext.getStore('category');
//proxy type is set to memory
console.log(categoryStore.getProxy());
categoryStore.setProxy({
type: 'ajax',
url: '/modules/BACKUP.php',
reader: {
type: 'json',
root: 'root'
},
actionMethods: {
create : 'POST',
read : 'POST',
update : 'POST',
destroy: 'POST'
}
});
//proxy type is set to ajax with url
console.log(categoryStore.getProxy());
categoryStore.load({
params: {
instanceId: '2',
action: 'fetchPaths'
},
scope : this,
callback: function (records, operation, success) {
console.log(records);
console.log(operation);
console.log(success);
console.log(operation.response.responseText);
}
});
}
},


onConfirm: function (choice) {
if (choice === 'yes') {
//
}
}
});