The difference between
http://forums.ext.net/showthread.php...ll=1#post96114 and the following example is that this one uses
BeforeLoad handler.
Using the following example, expand the first (unique) node and you will receive two alerts:
Validating Expansion and
Not Allowed. After you close both alerts, try to expand the node again and you'll note that the node is died but it is expected that the node expands successfuly.
Please let me know how you made it work.
Note: i download the latest version from SVN
1 - View
<!DOCTYPE html>
<html>
<head runat="server">
<title>Index</title>
<script type="text/javascript">
var isFirstLoad = true;
var beforeLoad = function (item, operation, options) {
alert('Validating Expansion');
if (isFirstLoad) {
alert('Not Allowed');
isFirstLoad = false;
operation.node.set("loading", false);
return false;
}
return false;
}
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TreePanel ID="TreePanel2" SelType="Checkbox" runat="server" Title="Tree" Height="700"
Width="400" Margins="10" RootVisible="false" Border="false">
<Listeners>
<BeforeLoad Handler="return beforeLoad(item, operation, options);" />
</Listeners>
<Store>
<ext:TreeStore ID="TreeStore1" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/loadNodeChildren">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Task" />
</Fields>
</ext:Model>
</Model>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="0" Text="Root" />
</Root>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Text="Task" Flex="2" Sortable="true"
DataIndex="Task" />
</Columns>
</ColumnModel>
</ext:TreePanel>
</body>
</html>
2 - Action
public StoreResult loadNodeChildren()
{
StoreResult result = new StoreResult();
NodeCollection nodes = new NodeCollection(false);
Node no = new Node();
no.NodeID = DateTime.Now.Second.ToString();
no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
nodes.Add(no);
result.Data = nodes.ToJson();
return result;
}