请教一个关于astreeview的使用问题
洳夢绚染 2012-01-09 11:48:08 前端
<ct:ASTreeView ID="astvMyTree" runat="server" AdditionalAddRequestParameters="{'t2':'ajaxAdd'}"
AdditionalLoadNodesRequestParameters="{'t1':'ajaxLoad'}"
BasePath="~/Javascript/astreeview/" DataTableRootNodeValue="-1"
EnableAjaxOnEditDelete="true"
EnableCheckbox="true" EnableContextMenu="true" EnableCustomizedNodeIcon="false"
EnableDebugMode="false" EnableDragDrop="false" EnableNodeIcon="true" EnableNodeSelection="true"
EnableRoot="false" EnableTreeLines="true" LoadNodesProvider="~/Default.aspx" AutoPostBack="True" />
后台代码
private void AddTree() //添加根节点
{
string para = "0";
List<T_Sys_Organizations> tso = new List<T_Sys_Organizations>();
tso = OrganManagerDao.SelectOrganizationsParentID3(para);
DataTable dt = ListToDataTable(tso); ;
ASTreeViewNode root = this.astvMyTree.RootNode;
foreach (DataRow dr in dt.Rows)
{
string productName = dr["ORG_Name"].ToString();
string productId = dr["ORG_ID"].ToString();
string parentId = dr["ORG_ParentID"].ToString();
int childNodesCount = int.Parse(dr["ORG_Count"].ToString());
ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
node.VirtualNodesCount = childNodesCount;
node.VirtualParentKey = productId;
node.IsVirtualNode = childNodesCount > 0;
node.NavigateUrl = "#";
//List<KeyValuePair<string, string>> attrs = new List<KeyValuePair<string, string>>();
node.AddtionalAttributes.Add(new KeyValuePair<string, string>("onclick", "return false;"));
//node.AddtionalAttributes = attrs;
root.AppendChild(node);
}
}
protected override void Render(HtmlTextWriter writer) //添加子节点
{
if (Request.QueryString["t1"] == "ajaxLoad")
{
string virtualParentKey = Request.QueryString["virtualParentKey"];
string para = "0";// "= 1";
if (virtualParentKey == null)
para = "0";
else
para = virtualParentKey;
List<T_Sys_Organizations> tso = new List<T_Sys_Organizations>();
tso = OrganManagerDao.SelectOrganizationsParentID4(para);
DataTable dt = ListToDataTable(tso); ;
ASTreeViewNode root = new ASTreeViewNode("root");
foreach (DataRow dr in dt.Rows)
{
string productName = dr["ORG_Name"].ToString();
string productId = dr["ORG_ID"].ToString();
string parentId = dr["ORG_ParentID"].ToString();
int childNodesCount = 0;
if (!string.IsNullOrEmpty(dr["ORG_Count"].ToString()))
childNodesCount = int.Parse(dr["ORG_Count"].ToString());
ASTreeViewLinkNode node = new ASTreeViewLinkNode(productName, productId);
node.VirtualNodesCount = childNodesCount;
node.VirtualParentKey = productId;
node.IsVirtualNode = childNodesCount > 0;
node.NavigateUrl = "#";
node.AddtionalAttributes.Add(new KeyValuePair<string, string>("onclick", "return false;"));
root.AppendChild(node);
}
HtmlGenericControl ulRoot = new HtmlGenericControl("ul");
astvMyTree.TreeViewHelper.ConvertTree(ulRoot, root, false);
foreach (Control c in ulRoot.Controls)
c.RenderControl(writer);
}
else
base.Render(writer);
}
现在的问题是展开根节点的时候只显示这个跟节点下边的子节点数目,不触发Render事件,请教要怎么改
控件是直接从例子上面拷贝过来的,AutoPostBack已经设定为True了