PDA

View Full Version : [RESOLVED] TreePanel and destroy treeLoader



leduc
30 Nov 2011, 7:55 AM
Hello all,

I have a problem with a TreePanel.
My TreePanel is in an Ext.Windows.
First Time: Click button on my web page, create the TreePanel, create the Windows, render my tree panel in the Windows.
My TreePanel have a reload function like this:


,reload: function(docId, mode, filterValue)
{
// Load the tree
this.getLoader().dataUrl = this.getTreeUrl;
this.getLoader().baseParams =
{
docId : docId
,mode : mode
,filterValue: filterValue
};
this.getRootNode().reload();


I have a function to make search on my TreePanel that call my reload function with specific values for docId, mode, filterValue.
All it's ok !! :) ... only the first time :s.

If I closed the Windows (destroy), and for the second time Click button to call Ext Windows and my TreePanel, display and rendered are ok, but I get the old baseParams, and so, a bad json for my TreePanel. If I make a new search or if I try to reset the TreePanel, it's the same, I keep the same json as if I make the previous search...

My treePanel have an autoDestroy, I test with a destroy when I closed the Windows, I try to destroy the loader with:


this.getLoader().destroy();


But nothing doing well.

Have you got some "Id" ? :)

Thanks for your help.

mitchellsimoens
30 Nov 2011, 11:53 AM
How is your tree loader put on your tree panel? Do you use Ext.extend to create your own class that extens tree panel?

leduc
1 Dec 2011, 12:03 AM
Hello Mitchell,

Thank you for your interest.

This is the code for my treePanel class:


DM.docTagsTreePanel = Ext.extend(Ext.tree.TreePanel,
{
id : ''
,split : true
,expanded : true
,xtype : 'treepanel'
,hideBorders: true

// tree-specific configs:
,rootVisible: false
,lines : true
,useArrows : true
,autoScroll : true
,animate : true
,containerScroll: true
,getTreeUrl : 'tree/getdeflist?ajax=1'
,root: {
root : 'root'
,nodeType : 'async'
,draggable : false
,expanded : true
,id : 'root'
}
,autoDestroy : true
,expandFlagAll : false
,docId : ''
,docType : ''
,parentWin : []

/*
* CONSTRUCTOR
*/
,initComponent: function(){
var thisTreePanel = this;
this.tbar = [
{
cls : 'x-btn-text-icon'
,icon : 'img/find.png'
,tooltip : DM.utils.translate('Press enter to validate')
},{
xtype : 'textfield'
,id : this.id+'treeProjectFilter'
,width : 120
,emptyText : DM.utils.translate('Filter on project code')
,name : DM.utils.translate('Project')
,listeners :
{
specialkey:this.listeners.doFilter
}
},{
xtype : 'tbfill'
},{
cls : 'x-btn-text-icon'
,xtype : 'tbbutton'
,icon : 'img/icons/arrow_refresh.png'
,tooltip : DM.utils.translate('Reset the project tree')
,handler : function ()
{
// unset filter value
Ext.getCmp(thisTreePanel.id+'treeProjectFilter').setValue('');
thisTreePanel.reload(thisTreePanel.docId, '', '');
}
}
];
this.on('click', this.onTreeNodeClick, this);

DM.tree.TreePanel.superclass.initComponent.apply(this,arguments);
this.reload(this.docId, '', '');
}
,listeners:
{
doFilter:function(frm,evt){
if(evt.getKey() == evt.ENTER)
{
var treeId = frm.id.replace('treeProjectFilter', '');
var tree = Ext.getCmp(treeId);
tree.reload(tree.docId, 'project', frm.getValue());
}
} // eo doFilter
}// eo listeners

,reload: function(docId, mode, filterValue)
{
// Test without success:
// this.getLoader().destroy();
// Load the tree
this.getLoader().dataUrl = this.getTreeUrl;
this.getLoader().baseParams =
{
docId : docId
,mode : mode
,filterValue: filterValue
};
this.getRootNode().reload();
}
[...]


In an other class, I call the TreePanel and the Ext.Windows to display it (there is other grids in this Windows, but I deleted them for the exemple).



//Before creating the TagsTreePanel we check that there is no existing previous one
if(Ext.getCmp('drawingTagsTreePanel')) Ext.getCmp('drawingTagsTreePanel').destroy();

var drawingTagsTreePanel = new DM.docTagsTreePanel(
{
id : 'drawingTagsTreePanel'
,docId : docId
,docType : 'drawing'
,parentWin : drawingTagsTreePanelWin
});

//Before creating the windows we check that there is no existing previous one
if(Ext.getCmp('drawingTagsTreePanelWin')) Ext.getCmp('drawingTagsTreePanelWin').destroy();

var drawingTagsTreePanelWin = new DM.documentTagsTreePanelWin({
id : 'drawingTagsTreePanelWin'
,title : DM.utils.translate('Tag a Drawing')
,tagTreePanel : drawingTagsTreePanel
});


The code works well the first Time I open the Windows, but after a close of the windows and a new creation, the loader baseParams have changed if I see firebug and console.log, but php server received a request with the baseParams of the loader state before closure of the Windows.

Thanks for your help.

leduc
1 Dec 2011, 2:38 AM
I try several others ways, but without success.

In fact my problem is:
How change baseParams on treePanel loader after a deletion of the same previous treePanel?

note: the id is different between the first and the second TreePanel

Thanks to help me.

leduc
1 Dec 2011, 3:03 AM
Other way with same result:
On my TreePanel constructor I add a set for the loader and disabled the call to method reload.


/*
* CONSTRUCTOR
*/
,initComponent: function()
{
var thisTreePanel = this;
this.setTitle(PDM.utils.translate('Project'));
// Build the loader
this.loader = new Ext.tree.TreeLoader(
{
id : 'treeLoader'+this.docId
,dataUrl : 'tree/getdeflist/docId/'+this.docId+'?ajax=1'
,autoload : true
}); // eof store


The both TreePanel are distinct Id and distinct Loader.
In firebug, I get correct object with different loader and different url to load, but php always get the same request and so, return the same answer !! :(

mitchellsimoens
1 Dec 2011, 5:26 AM
I believe it is because of the root property you are setting outside a method so it is getting shared across all instances. Please place the root config within the initComponent and see if that helps.

leduc
1 Dec 2011, 5:40 AM
One more time, you are right !!!
I add this code whithin the iniComponent: function()


this.root = {
root : 'root'
,nodeType : 'async'
,draggable : false
,expanded : true
,id : 'root'
};


And the tree call the good baseParams.
Thank you Mitchell !!!

PS: How I can add a resolved tag?

mitchellsimoens
1 Dec 2011, 5:41 AM
Edit your original post in advanced mode and you can edit the title with [RESOLVED] or [ANSWERED]

leduc
1 Dec 2011, 5:53 AM
In fact, I can not access to advanded mode when I edit my first post, I get an error:
PATHS is not defined
http://www.sencha.com/forum/clientscript/vbulletin_quick_edit.js?v=415
Line 11

If you can Edit the title and if you think this will be interesting, could you please do it?
Thank you very much for your help.

mitchellsimoens
1 Dec 2011, 6:18 AM
In fact, I can not access to advanded mode when I edit my first post, I get an error:
PATHS is not defined
http://www.sencha.com/forum/clientscript/vbulletin_quick_edit.js?v=415
Line 11

If you can Edit the title and if you think this will be interesting, could you please do it?
Thank you very much for your help.

I have heard of this error but I do not see it. What browser/version are you using?

leduc
1 Dec 2011, 6:25 AM
If I can help you !!! ;-))

Firefox 7.0
IE8.0.7600
Windows 7 Pro 64B

and same thing with:

FireFox 6.0
OpenSuse 11.4 64B

mitchellsimoens
1 Dec 2011, 6:34 AM
Thank you very much! Past it onto our web team \:D/

leduc
1 Dec 2011, 6:38 AM
You are welcome !!!
Read you soon.