May 29, 2012, 2:28 PM
[CLOSED] Append a fully loaded child in a remote TreePanel
Hi folks, i have a TreePanel that uses an AjaxProxy to perform the load of child nodes. It works perfectly but i have a scenario that i need to append a "fully" loaded node.
In the example bellow when the _btnAppendSubTree Button is clicked a node with three levels is loaded. but when i expand the it, the load of sub-items is performed, but i just want to show the item previously loaded.
In version 1.x of Ext.Net i could set whether nodes were async by instantiate it as Node or AsyncNode. Is there any way to inform that the node is not async?
1 - View
In the example bellow when the _btnAppendSubTree Button is clicked a node with three levels is loaded. but when i expand the it, the load of sub-items is performed, but i just want to show the item previously loaded.
In version 1.x of Ext.Net i could set whether nodes were async by instantiate it as Node or AsyncNode. Is there any way to inform that the node is not async?
1 - View
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Button ID="_btnAppendSubTree" runat="server" Text="Append Sub Tree">
<Listeners>
<Click Handler="AppendSubTree();" />
</Listeners>
</ext:Button>
<ext:TreePanel ID="TreePanel1" runat="server" Icon="Accept" Height="300" Shadow="false"
UseArrows="true" AutoScroll="true" Animate="true" EnableDD="true" RootVisible="false">
<Fields>
<ext:ModelField Name="Task" />
</Fields>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn2" runat="server" Text="Task" DataIndex="Task" />
</Columns>
</ColumnModel>
<Store>
<ext:TreeStore ID="TreeStore1" NodeParam="nodeId" AutoLoad="true" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/loadNodeChildren/">
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="0" Text="Tasks" />
</Root>
</ext:TreePanel>
2 - JavaScriptvar AppendSubTree = function () {
Ext.net.DirectMethod.request({
url: "/Example/AppendSubTree",
cleanRequest: true,
success: function (result) {
App.TreePanel1.getRootNode().appendChild(Ext.decode(result.data));
}
});
}
3 - Controllerpublic StoreResult loadNodeChildren(string nodeId)
{
NodeCollection nodes = new NodeCollection(false);
if (!string.IsNullOrEmpty(nodeId))
{
for (int indice = 1; indice < 6; indice++)
{
Node no = new Node();
no.NodeID = nodeId + indice;
no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
nodes.Add(no);
}
}
return new StoreResult { Data = nodes.ToJson() };
}
public StoreResult AppendSubTree(string nodeId)
{
NodeCollection nodes = new NodeCollection(false);
Node no = new Node();
no.NodeID = "sub0";
no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
nodes.Add(no);
Node subNode1 = new Node();
subNode1.NodeID = "sub1";
subNode1.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = subNode1.NodeID, Mode = ParameterMode.Value });
no.Children.Add(subNode1);
Node subNode2 = new Node();
subNode2.NodeID = no.NodeID + "sub2";
subNode2.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = subNode2.NodeID, Mode = ParameterMode.Value });
subNode1.Children.Add(subNode2);
return new StoreResult { Data = nodes.ToJson() };
}
Last edited by Daniil; Jun 04, 2012 at 7:43 PM.
Reason: [CLOSED]