Jan 26, 2012, 3:11 PM
[CLOSED] Reload treepanel dynamically
Hi
I have following problem: based on some filter from user i have to reload the whole treegrid for the simplicity let's take a treepanel. the filter is only applied on the children of root.
My solution: the filter criteria is submitted as extraparameters of the (page)loader. The NodeLoad method loads the children nodes based on the filter submitted.
Following is a simplified example based on https://examples1.ext.net/#/TreePane...ageTreeLoader/.
In this example i am showing the problem I have, namely changing the loader's baseparameter will not be reflected in the nodeLoad method. This example is supposed to load the tree each time when the refresh button is clicked, and clicking this button will change the BaseParameter and then loads Root node again. but this modified Baseparameter is not transmitted to the nodeload(). how can I achieve such functionality?
Thanks.
I have following problem: based on some filter from user i have to reload the whole treegrid for the simplicity let's take a treepanel. the filter is only applied on the children of root.
My solution: the filter criteria is submitted as extraparameters of the (page)loader. The NodeLoad method loads the children nodes based on the filter submitted.
Following is a simplified example based on https://examples1.ext.net/#/TreePane...ageTreeLoader/.
In this example i am showing the problem I have, namely changing the loader's baseparameter will not be reflected in the nodeLoad method. This example is supposed to load the tree each time when the refresh button is clicked, and clicking this button will change the BaseParameter and then loads Root node again. but this modified Baseparameter is not transmitted to the nodeload(). how can I achieve such functionality?
Thanks.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>TreePanel with Async TreeLoader using Page - Ext.NET Examples</title>
<link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
<script runat="server">
protected void NodeLoad(object sender, NodeLoadEventArgs e)
{
//string prefix = e.ExtraParams["prefix"] ?? "";
string prefix = TreePanel1.Loader[0].BaseParams[0].Value ?? "";
if (!string.IsNullOrEmpty(e.NodeID))
{
for (int i = 1; i < 6; i++)
{
AsyncTreeNode asyncNode = new AsyncTreeNode();
asyncNode.Text = prefix + e.NodeID + i;
asyncNode.NodeID = e.NodeID + i;
e.Nodes.Add(asyncNode);
}
for (int i = 6; i < 11; i++)
{
Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
treeNode.Text = prefix + e.NodeID + i;
treeNode.NodeID = e.NodeID + i;
treeNode.Leaf = true;
e.Nodes.Add(treeNode);
}
}
}
protected void Refresh_Clicked(object sender, DirectEventArgs args)
{
TreePanel1.Loader[0].BaseParams[0].Value = DateTime.Now.ToLongTimeString();
TreePanel1.ReloadAsyncNode("root_id", null);
}
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<h1>TreePanel using PageTreeLoader</h1>
<p>Set custom node prefix: </p>
<ext:Button ID="Button_Refresh" runat="server" Text="Refresh">
<DirectEvents>
<Click OnEvent="Refresh_Clicked"></Click>
</DirectEvents>
</ext:Button>
<ext:TreePanel
ID="TreePanel1"
runat="server"
Title="Tree"
AutoHeight="true"
Border="false">
<Loader>
<ext:PageTreeLoader OnNodeLoad="NodeLoad">
<BaseParams>
<ext:Parameter Name="prefix" Value="1" Mode="Value" />
</BaseParams>
</ext:PageTreeLoader>
</Loader>
<Root>
<ext:AsyncTreeNode NodeID="root_id" Text="Root" />
</Root>
</ext:TreePanel>
</form>
</body>
</html>
Last edited by Daniil; Jan 27, 2012 at 3:28 PM.
Reason: [CLOSED]