PDA

View Full Version : ExtJS tree node selection confirm



yroman
1 Mar 2010, 12:34 AM
Hi,

I have a task where each tree node selection should be confirmed by user. For example user clicks on the node (or moves to the node via keyboard), than confirm dialog should appear with confirmation for node selection. And only when the user presses ok button tree node should be selected (and some actions should appear after).

It is easy to do using javascript confirm via adding this confirm to beforeselect listener and returning confirm result.

The main problem here is that I'm required to use Ext.MessageBox confirmation dialog. This dialog is async so I can't simply do the same as for javascript confirm.

I could handle this problem for example by always returning false and performing actual node selection in the dialog callback, but is is not easy and requires additional flags or some else:

beforeselect: function(cmp, node) {
Ext.MessageBox.confirm('title', 'message', function() {
cmp.getSelectionModel().select(node);
});
return false;
}


The code above simply doesn't work because we have a loop here :\
I could add some flags etc. to handle this but it seems to be very hacky.

So I need another solution to this problem.

Thank you!

BlueCamel
1 Mar 2010, 4:58 AM
Suspend events before you select the node in the call back.