请教一个关于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了
...全文
189 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hujx26 2012-07-23
  • 打赏
  • 举报
回复
删除代码里的
node.AddtionalAttributes.Add(new KeyValuePair<string, string>("onclick", "return false;"));
洳夢绚染 2012-01-09
  • 打赏
  • 举报
回复
这个我自己搞定了 换一个问题 也是aastreeview的
<ct:ASTreeView ID="astvMyTree"
runat="server"
DataTableRootNodeValue="-1"
EnableRoot="false"
EnableNodeSelection="true"
EnableCheckbox="true"
EnableDragDrop="true"
EnableTreeLines="true"
EnableNodeIcon="true"
EnableCustomizedNodeIcon="false"
AutoPostBack ="true"
EnableDebugMode="false"
EnableContextMenu="true"
EnableAjaxOnEditDelete="true"
AdditionalLoadNodesRequestParameters="{'t1':'ajaxLoad'}"
BasePath="~/Javascript/astreeview/"
LoadNodesProvider="~/OrganManager/OrganIndex.aspx"
OnOnSelectedNodeChanged="astvMyTree_OnSelectedNodeChanged" />
后台用代码加载的项,结果单击某项的时候不能触发astvMyTree_OnSelectedNodeChanged这个事件,请问这个是为什么?要怎么解决?

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧