请教一个关于astreeview的使用问题

洳夢绚染 洳夢绚染 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
前端
<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了
...全文
评论 2
收藏 已收藏
分享
返回顶部
洳夢绚染
.NET社区 62,272 成员 668,968 内容