PDA

View Full Version : Tree panels differences



akoval
3 Nov 2012, 8:45 AM
Recently ceased to understand that occurs.

There are two tree panels.
1st created when browser load document.
Viewport... region "west"...items:


title: Ext.app.locale.LocaleManager.get("dbApplication.config_title"),
padding:'0 0 0 0',
autoScroll: true,
items:[{
xtype : 'treepanel',
id: 'config_tree',
hideHeaders: true,
rootVisible: false,
collapsible: false,
heigh:'100%',
width : '100%',
store: Ext.create('Ext.data.TreeStore', {
proxy: {
.....
},
type: 'ajax',
.....
},
autoLoad:false,
clearOnLoad: true,
root: {
text: 'root',
id: 'root',
expanded: true
}
}),
listeners:{
itemclick:function( tree, record, itemHtml, index, e, eOpts ){
Ext.getCmp('export_rules_del_button').setDisabled(false);
Ext.getCmp('center_panel').getLoader().load({
params: {
mode: record.get("id"),
action: 'get_main_panel'
}
});
}
}
}]


The information


{ "children":[
{"id":"db_lang","text":"Languages set","leaf":true},
{"id":"cron_jobs","text":"Cron jobs execution","leaf":true},
{"id":"users_groups","text":"Users and Groups","leaf":true}
] }
loaded in tree and when user select the node, in the itemclick event I have record with proper ID.
By the click on this tree node in the center panel load other trees:

{
layout: {
type: 'hbox',
pack: 'start',
align: 'stretch'
},
items:[{
flex: 1,
xtype: 'groups_users_tree',
id: 'groups_users',
title: 'Groups'
},{
flex: 1,
xtype: 'users_tree',
id: 'users',
title: 'Users list'
},{
title: 'Info',
width: 500
}]
}
The users tree panel has the definition:


Ext.define('Ext.ux.Users', {
extend: 'Ext.panel.Panel', // subclass Ext.Component
alias: 'widget.users_tree',
initComponent: function(){
this.clipBoard = null;
Ext.apply(this, {
layout: 'fit',
style:{
margin:'0px',
padding: '0px'
},
scroll: true,
autoScroll: true,
items:[{
xtype : 'treepanel',
id: 'users_list',
hideHeaders: true,
rootVisible: false,
collapsible: false,
heigh: 'auto',
width : 'auto',
store : userStore,
listeners:{
itemclick:function( treeView, record, item, index, e, eOpts ){
alert("Item select:"+record.get("id"));
Ext.getCmp('users_list').selected_node_id = record.get("id");
}
}
. . .

Info for second tree


{
"success": true,
"children":[
{"id:":"u_1","text":"admin","leaf":true},
{"id:":"u_2","text":"admin2","leaf":true},
{"id:":"u_3","text":"creative","leaf":true}
]
}

All are loaded and showed well. But when I click on the node in the Users tree the record has not id.
I don't understand, why for 1st tree (in west region) in event itemclick I have record with id and for 2nd tree in the same event (itemclick) the id is empty?
I was trying on Exts 4.0.1 and 4.1.1a with the same results.
Thank's

vietits
3 Nov 2012, 5:48 PM
It's strange. I see no problem with your 'itemclick' handling codes. So try to debug to see what userStore, record have.


listeners:{
itemclick:function( treeView, record, item, index, e, eOpts ){
alert("Item select:"+record.get("id"));

console.log(userStore, record, record.getId());


Ext.getCmp('users_list').selected_node_id = record.get("id");
}
}

akoval
4 Nov 2012, 2:58 AM
Thank's

I put the log(....) to the itemclick in the Config tree and to the Users tree.

console.log(userStore, record, record.getId());

The store have the same structure with differences for config values.

But the "record" are different.
For Config the record is:





$className
"Ext.data.Store.ImplicitModel-ext-gen1038"



$hasInheritableStatics
Object { setProxy=
true, getProxy=
true, setFields=
true, more...}



$inheritableStatics
[
"setProxy",
"getProxy",
"setFields", 2 more...]



_singleProp
Object {}



alternateClassName
"Ext.data.Record"



associations
Object { items=[0], map={...}, keys=[0], more...}



childNodes
[]



clientIdProperty
null



config
Object {}



configMap
Object {}



data
Object { text=
"Users and Groups", id=
"users_groups", parentId=
"root", more...}



allowDrag
true



allowDrop
true



checked
null



children
null



cls
""



depth
1



expandable
true



expanded
false



href
""



hrefTarget
""



icon
""



iconCls
""



id
"users_groups"



index
2



isFirst
false



isLast
true



leaf
true



loaded
false



loading
false



parentId
"root"



qtip
""



qtitle
""



root
false



text
"Users and Groups"



defaultProxyType
"ajax"








The data.id has value "users_groups".
For the Users tree the record in the itemclick event is:





$className
"User"



$hasInheritableStatics
Object { setProxy=
true, getProxy=
true, setFields=
true, more...}



$inheritableStatics
[
"setProxy",
"getProxy",
"setFields", 2 more...]



_singleProp
Object {}



alternateClassName
"Ext.data.Record"



associations
Object { items=[0], map={...}, keys=[0], more...}



childNodes
[]



clientIdProperty
null



config
Object {}



configMap
Object {}



data
Object { text=
"creative", parentId=
"root", index=
2, more...}



allowDrag
true



allowDrop
true



checked
null



children
null



cls
""



depth
1



expandable
true



expanded
false



href
""



hrefTarget
""



icon
""



iconCls
""



index
2



isFirst
false



isLast
true



leaf
true



loaded
false



loading
false



parentId
"root"



qtip
""



qtitle
""



root
false



text
"creative"



defaultProxyType
"ajax"






Here the data.id not exists...
The value of record.internalId for Config tree is "users_groups" - Record ID
For the Users tree this value is - "ext-record-58" - not Record ID.
record.id for Config tree is "Ext.data.Store.ImplicitModel-ext-gen1038-users_groups",
For Users tree- "ext-record-58"

The main difference between tress is the Users tree is loaded dynamically.

akoval
4 Nov 2012, 3:11 AM
I mean load dynamically

Ext.geCmp('center_panel').getLoader().load({...});

BTW.
1) I was trying different ways for Users Tree with the store - internal store definition/global store definition, as for a tree "groups_users_tree" with the same results - record id is not exists
2) Record id can be found in the "record.raw" array, but why record.get('id') return empty result?

akoval
6 Nov 2012, 5:15 AM
I found the problem. My mistake....

"id:":"u_1","text":"admin","leaf":true

Thanks for attention