PDA

View Full Version : Problem with TreePanel



1099511627776
6 Dec 2011, 12:40 PM
Hello,
I have a problem with treePanel visualization.
When I create treepanel for the first time ans initialize it with json data. it looks like this:
29833
That is not good.
But after I reload it (close the Ext.Window and reopen it) once more Tree shows OK
29834
Why it does not show right on a first load.
P.S. JSON - data is same in the first and the second "load"
P.P.S Using ExtJS 4.0

mitchellsimoens
6 Dec 2011, 1:58 PM
Do you return the checked config for the nodes? If the checked config isn't there, it shouldn't display the check.

1099511627776
6 Dec 2011, 11:02 PM
Do you return the checked config for the nodes? If the checked config isn't there, it shouldn't display the check.
No I do not use any "checkbox" commands in my config and in JSON data.
My tree creation code is:


this.treeStore = Ext.create('Ext.data.TreeStore',{
root: {
text:'Дерево деталей',
id:0,
expanded:false
},
sorters:[
{sorterFn:function(o1,o2){
var p1 = o1.raw.sort_id;
var p2 = o2.raw.sort_id;
if (p1 === p2){
return 0
}
return (p1 < p2) ? -1:1;
}}
],
autoload:false,
proxy:catalog_config
});
..........
this.treePanel = Ext.create('Ext.tree.TreePanel',{
flex: 1,
title: 'Дерево деталей',
height:'100%',
store: this.treeStore,
});

and JSON Response is:


[
{"text": "\u041b\u0435\u0433\u043a\u043e\u0432\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438", "sort_id": 1, "leaf": false, "id": 10001},
{"text": "\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f", "sort_id": 965, "leaf": false, "id": 20002},
{"text": "\u0414\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c", "sort_id": 1720, "leaf": false, "id": 30003},
{"text": "\u041e\u0441\u044c", "sort_id": 1948, "leaf": false, "id": 40004}]

1099511627776
7 Dec 2011, 7:17 AM
Another problem with treePanel.
When i do reconfigure and store.load it deletes the first child element or the root and raises an exception:

uncaught exception: You are using a ServerProxy but have not supplied it with a url.
http://localhost/site/extjs/ext-debug.js
Line 12151
I'm reloading using this code:


this.treeStore.proxy.extraParams = {list:'tree',typeid:record.data.code};
this.treeStore.proxy.setModel('asv.model.tree');
this.treePanel.store.load();
this.treePanel.reconfigure();

But i'm sure that I've specified url in a proxy.
Besides that, when i reload it 4 times (everty time i reload, the treepanel keep deleting root children one by one) it reloads all tree children normally

1099511627776
8 Dec 2011, 11:12 AM
After hours of debugging I've found a workaround and i hope that developers can explain that.
The problem is:
The first child element is filled with all properties:









allowDrag
true



allowDrop
true



checked
null



cls
""



depth
1



expandable
true



expanded
true



href
null



hrefTarget
null



icon
null



iconCls
null



id
10001



index
0



isFirst
true



isLast
false



leaf
false



loaded
true



loading
false



parentId
"0"



qtip
null



qtitle
null



root
false



text
"Легковые автомобили"






But all other child elements have no have no properties:
"expandable","expanded" and property "checkbox" is defined with "undefined".
A workaround is to modify there properties in append event:
Listener in TreeStore:

listeners:{
append:function(thisNode,newChildNode,index,eOpts){
if( !newChildNode.isRoot() ){
newChildNode.set("checked",null);
newChildNode.set("cls",null);
newChildNode.set("expandable",(newChildNode.data.leaf == false));
newChildNode.set("expanded",false);
console.log(newChildNode);
}
}
}