PDA

View Full Version : TreeStore didn't expand after collapse



benny_GI
13 Apr 2014, 4:56 AM
hi, i'm new in extjs and i hope you can understand my english.

my problem: i have a viewport with store, a model for the store and items. at the items are some tabpanels, which need the same store, so as i initialize the tabpanels i delivered the store to them. that works perfectly and i see the treestore in both tabpanels.

BUT: if i collapse a branch from the treestore in one tabpanel and switch to an other tabpanel with the same treestore, i can't expand the branch, which i collapsed before.

has anyone an idea? please let me know. thx

scottmartin
13 Apr 2014, 4:13 PM
It would help to see your code. You can create an example in our fiddle:
https://fiddle.sencha.com/#home

Sounds like you are destroying something you should not be, or that you have duplicate id that is causing a collision.

benny_GI
14 Apr 2014, 3:38 AM
ok, here you can see some code:

mainmenu:

Ext.define('Mainmenu', {
requires: [
'Ext.data.*',
'Ext.tree.*',
'Ext.tab.*'
],
extend: 'Ext.util.Observable',
constructor: function() {

var modelNutzer = Ext.extend(Ext.data.Model, {
fields: [
{ name:'text', type:'string' },
{ name:'online', type:'boolean' },
{ name:'sv', type:'boolean' },
{ name:'aktiv', type:'boolean' },
{ name:'nutzer_id', type:'integer' },
{ name:'type', type:'integer' }
]
});

var storeNutzer=this.storeNutzer = Ext.create('Ext.data.TreeStore', {
model: modelNutzer,
proxy: {
type: 'ajax',
url: config.server +'/?usertab',
pageParam: undefined,
startParam: undefined,
sortParam: undefined,
noCache: true
},
autoLoad: true,
});

var tabpage =this.tabpage= new Tabpage({storeNutzer:storeNutzer});

var viewport=my.viewport = new Ext.Viewport({
closable: false,
collapsible: false,
plain: true,
layout: 'border',
items:[{
region: 'north',
layout: 'hbox',
border: false,
maxHeight:55,
items: [ ... ]
}
,tabpage.tab
]}
);
}
});

tabpage:


Ext.define('Tabpage', {
requires: [
'Ext.grid.PropertyGrid.*',
'Ext.tree.*'
],

constructor: function(options) {
var usertab = new Usertab({storeNutzer:options.storeNutzer});
var accesstab = new Accesstab({storeNutzer:options.storeNutzer});
var tab=this.tab = new Ext.tab.Panel({
region: 'center',
items: [
usertab.grid,
accesstab.view,
...
],
});
}
});

usertab:


Ext.define('Usertab', {
requires: [
'Ext.tree.*',
'Ext.data.*',
'Ext.form.*',
'Ext.grid.*'
],

constructor: function(options) {
var store=this.store =options.storeNutzer;
var grid=this.grid = new Ext.tree.Panel({
title: 'Nutzer',
itemId: 1,
layout: 'fit',
store:store,
useArrows: true,
rootVisible: false,
multiSelect: true,
rowLines:true,
columnLines:true,
maxWidth: 500,
height: 150,
},
columns: [{
xtype: 'treecolumn',
resizable: false,
flex:3,
sortable: true,
dataIndex: 'text',
menuDisabled: true,
editor: {xtype: 'textfield'},
}, {
text: 'Online',
resizable: false,
xtype: 'checkcolumn',
dataIndex: 'online',
maxWidth:70,
sortable: false,
menuDisabled: true,
},
...
}]
});

accesstab:


Ext.define('Accesstab', {
requires: [
'Ext.grid.*',
'Ext.tree.*',
'Ext.data.*',
'Ext.data.Model',
],

constructor: function(options) {
var storeNutzer=this.storeNutzer =options.storeNutzer;
var usertree= new Ext.create('Ext.tree.Panel',{
store: storeNutzer,
itemId:0,
rootVisible: false,
border: true,
useArrows: true,
title: 'Nutzer',
titleAlign: 'center',
region: 'west',
width:200,
collapsible: true,
collapsed:false,
titleCollapse: true,
});
[...] // var usertree will be integrated in other panels


i hope somebody can help :)

benny_GI
13 May 2014, 4:15 AM
hello, i tried some things and got intermediate result. necessary to know is my other problem: to add a node to the tree. if i try this, i get an error: Uncaught TypeError: undefined is not a function
i think, both problems have the same reason. i tried, only to add a child to the tree, like this: https://fiddle.sencha.com/#fiddle/1rg the important fact, which stroke out is, i tried to define somesthing with Ext.define and create some thing in the constructor, but in the example from fiddle, this use Ext.application and the launch-function. after this, i read a book about Ext.define and Ext.application, but i don't understand the different and how can i resolve my problem with using Ext.define() ??