PDA

View Full Version : TreeNode selectionChange problem



kssen2004
28 Jun 2010, 2:01 AM
Hi everyone..
I have some listener problem in Ext.tree.DefaultSelectionModel.I have created Treepanel on the left side of the page. If i clicked any treenode, Formpanel would be displayed on the right side. My application is before changing any treenode, i would do checking whether any data has changed on rightside or not. If yes, then MessageBox(i am using Ext.MessageBox.show) will appear along with "do you want to navigate?" I added listener 'selectionChange' in DefaultSelectionModel. Like...

selectionModel.addListener('selectionChange',this.nodeSelectionChange, this);

This is working fine. If the treenode changed, the selected node highlights with blue color. My problem is, if the MessageBox comes means data changed on rightside, the selecednode highlights is not working. The highlights with blue color stands on the previous treenode.
I think the listener 'selectionChange' is getting lost due to the Ext.MessageBox.show window. Its taking Ext.MessageBox's listener...

Please give me a solution... Thanks

Animal
28 Jun 2010, 2:07 AM
I think it is working. It's just highlighting below the mask, and while your attention is on the Ext.MessageBox.

By the time you've clicked the button, the highlight effect has finished.

kssen2004
28 Jun 2010, 3:09 AM
Thanks for reply..

The highlight effect is not moving at all.
for example i've two nodes on my treepanel.. Namely
1. abc
2. def
I've modified some thing in abc panel and clicked def node without saving. so hence the Ext.MessgeBox is fired(i configured) but the highlight effect stands on the same node(abc) even i navigated to def panel. I've to click one more time the def node to get highlighted.
But if there is no Ext.MessgeBox window, it is working fine.

Animal
28 Jun 2010, 3:44 AM
You have to show code.

I just tested it on the console command line...



Ext.get("id-of-the-tree-node-div").highlight();Ext.Msg.alert("foo", "bar")


And I see the yellow highlighting happening behind the mask.

kssen2004
28 Jun 2010, 4:25 AM
My code
var selectionModel = new Ext.tree.DefaultSelectionModel();
var treePanel = new Ext.tree.TreePanel({
title: 'Test',
animate: false,
border: false,
style: {width: 250},
autoScroll: true,
selModel: selectionModel,
treeType: this.config.treeType
});

// Add event handlers here.
selectionModel.addListener('selectionChange',this.nodeSelectionChange, this);

Then i'm adding root and child nodes. See whenever a node is changing, the selected node got highlighted. But only problem is, if Ext.messagebox is fired(i clicked ok) when navigating one node to another node that highlight effect is not getting highlighted on the destination node, it still stands on the source node. Even i had tested by adding alert on the odeSelectionChange function. Normal mode the alert is fired. but in Ext.messagebox scenario the alert is not fired.

Animal
28 Jun 2010, 4:26 AM
I don't understand that.

You need to show code.

kssen2004
28 Jun 2010, 6:07 AM
I'm explaining step by step..

1. I created Treepanel.

var selectionModel = new Ext.tree.DefaultSelectionModel();
var treePanel = new Ext.tree.TreePanel({
title: 'Test',
animate: false,
border: false,
style: {width: 250},
autoScroll: true,
selModel: selectionModel,
treeType: this.config.treeType
....
....
});

2. I created Ext.tree.DefaultSelectionModel and defined it to treepanel selmodel. Created listener for DefaultSelectionModel as below
// Add event handlers here.
selectionModel.addListener('selectionChange',this.nodeSelectionChange, this);

nodeSelectionChange : function(
selModel /*Ext.tree.DefaultSelectionModel*/,
treeNode /*Ext.tree.TreeNode*/) {
alert('Node has changed')
}
Whenever a node is changing, the above method would be fired as Node has changed.

The nodeSelectionChange function is getting executed while moving one node to another node like

treenode-one ----> treenode-two

So, treenode-two is highlighted.

Only problem is the nodeSelectionChange function is not getting executed in below scenario.

treenode-one ----> Ext.Messagebox.window(i configured for validation) ---> treenode-two.

So that, highlight effect is still stands on treenode-one. but treenode-two function is executed.

Sorry i can't share the complete code..
Thanks

Animal
28 Jun 2010, 6:53 AM
I can't make head or tail of what you are saying.