zk的问题,200分急问,明早会加分

antony0203 2009-04-01 07:07:37
<tabs>
<tab id="UFP" label="部门列表" />
<tab id="OPP" label="菜单列表" />

</tabs>
<tabpanels>
<tabpanel>
<tree id="tree" width="100%" mold="paging">
<treecols>
<treecol />
</treecols>
<treechildren>

<treeitem>
<treerow>
<treecell label="Item 1" />
</treerow>
<treechildren>
<treeitem>
<treerow>
<treecell label="Item 1.1"/>
</treerow>


部分代码如上,想让部门结构按照这样的树结构显示,但是demo里是固定写死的,我希望是根据我数据库读取的部门组织列表显示,并且treecell还应该带有该部门名称对应的code。这个需求该怎么做?或者不能用tree的话,该用什么组件来实现呢?
有用过zk的进来帮帮忙吧
...全文
122 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gameboy911 2009-04-07
  • 打赏
  • 举报
回复
demo里有个动态树的,可以参照下那个代码
mumu_java 2009-04-07
  • 打赏
  • 举报
回复
没用过zk,这种常用js实现,帮顶。
阿云ivan 2009-04-06
  • 打赏
  • 举报
回复
zk是什么东东?
antony0203 2009-04-05
  • 打赏
  • 举报
回复
我想要的是zk框架下怎么做,它自带组件的
  • 打赏
  • 举报
回复
TreeView

private void PopulateRootLevel()
{
string connectionString = ConfigurationManager.ConnectionStrings["MySqlProviderConnection"].ConnectionString;
SqlConnection objConn = new SqlConnection(connectionString);
SqlCommand objCommand = new SqlCommand(@"select DepartmentID,DepartName,(select count(*) FROM Accounts_Department WHERE ParentDepartID=sc.DepartmentID) childnodecount FROM Accounts_Department sc where ParentDepartID=0", objConn);
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, TreeView1.Nodes);
}

private void PopulateSubLevel(int parentid, TreeNode parentNode)
{
string connectionString = ConfigurationManager.ConnectionStrings["MySqlProviderConnection"].ConnectionString;
SqlConnection objConn = new SqlConnection(connectionString);
SqlCommand objCommand = new SqlCommand(@"select DepartmentID,DepartName,(select count(*) FROM Accounts_Department WHERE ParentDepartID=sc.DepartmentID) childnodecount FROM Accounts_Department sc where ParentDepartID=@ParentDepartID", objConn);
objCommand.Parameters.Add("@ParentDepartID", SqlDbType.Int).Value = parentid;
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, parentNode.ChildNodes);
}


protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
PopulateSubLevel(Int32.Parse(e.Node.Value), e.Node);
}

private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
{
foreach (DataRow dr in dt.Rows)
{
TreeNode tn = new TreeNode();
tn.Text = dr["DepartName"].ToString();
tn.Value = dr["DepartmentID"].ToString();
tn.NavigateUrl = "departmentMain.aspx?id=" + dr["DepartmentID"].ToString();
tn.Target = "content";
nodes.Add(tn);

//If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = ((int)(dr["childnodecount"]) > 0);
}
}
caffeewithcoke 2009-04-04
  • 打赏
  • 举报
回复
jiefen
chang1216 2009-04-04
  • 打赏
  • 举报
回复
这个跟asp 一样的 从数据库中获取 所有部门 然后do while 循环一下 就可以了

52,792

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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