PDA

View Full Version : [CLOSED] [4.2.0b] Returning false from TreePanel beforeitemexpand makes the node unexpandable



Daniil
27 Dec 2012, 1:37 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.2.0 beta

Browser versions tested against:

Chrome
IE9

DOCTYPE tested against:

<!DOCTYPE html>

Description:

Returning false from a TreePanel's beforeitemexpand listener makes the node unexpandable and the beforeitemexpand event is not fired anymore.
The same behavior is with the TreeStore's beforeexpand and beforeload events.
This is related to this bug report.


http://www.sencha.com/forum/showthread.php?226335


Steps to reproduce the problem:

Expand the Root
A JavaScript confirmation box appears
Click Cancel
Try to expand the Root again

The result that was expected:

The node remains expandable

The result that occurs instead:

The node becomes unexpandable and the beforeitemexpand event is not fired anymore.

Test Case:

<!DOCTYPE html>
<html>
<head>
<title>TreePanel/TreeStore BeforeLoad Bug</title>

<link rel="stylesheet" href="../resources/css/ext-all.css" />

<script src="../ext-all.js"></script>

<script>
Ext.onReady(function () {
Ext.create("Ext.tree.Panel", {
renderTo: Ext.getBody(),
height: 300,
width: 300,
root: {
expanded: false,
text: "Root",
children: [{
text: "Node1"
}, {
text: "Node2"
}, {
text: "Node3"
}]
},
listeners: {
beforeitemexpand: {
fn: function () {
return confirm("Allow?");
}
}
}
});
});
</script>
</head>
<body>

</body>
</html>

mitchellsimoens
27 Dec 2012, 6:36 AM
Thanks for the report! I have opened a bug in our bug tracker.

Daniil
4 Jan 2013, 2:23 AM
The node's isExpandingOrCollapsing flag is not reset if return false.

So, resetting it manually appears to be a solution for now.

Example

var allow = confirm('Really?');

if (!allow) {
node.isExpandingOrCollapsing = false;
return false;
}