zoukankan      html  css  js  c++  java
  • 支持树型的GridView控件

     

    支持树型的GridView

    实现思路: 继承自Gridview,处理gridview的数据源,使其在帮定时,就已经按照树型菜单顺序排列好,那样只需在帮定处理其图片是javascript脚本就可以了

    源代码下载:https://files.cnblogs.com/wschacker/TreeListView.rar

    效果图:

    代码:

    Code
     public class TreeListViewRow : GridViewRow
        
    {
            
    public TreeListViewRow(int rowIndex, int dataItemIndex, DataControlRowType rowType, DataControlRowState rowState)
                : 
    base(rowIndex, dataItemIndex, rowType, rowState)
            
    {

            }

            
            
    protected override void OnPreRender(EventArgs e)
            
    {
                
    base.OnPreRender(e);
                
    if (this.RowType == DataControlRowType.DataRow)
                
    {
                    
    if (this.Parent.Parent is TreeListView)
                    
    {
                        TreeListView treeListView 
    = this.Parent.Parent as TreeListView;
                        DataRow dr 
    = ((DataTable)treeListView.DataSource).Rows[this.DataItemIndex] as DataRow;
                        
    string str = GetTreeNodeImg(dr, Convert.ToBoolean(dr["TreeListView$Row$IsLeaf"]), Convert.ToBoolean(dr["TreeListView$Row$IsBottom"]));
                        
    this.Cells[treeListView.NodeColumnIndex].Text = str + this.Cells[treeListView.NodeColumnIndex].Text;
                        
    this.ID = dr["TreeList$ViewRow$ClientID"].ToString();
                        
    if (treeListView.ExpendDepth > 0)
                        
    {
                            
    this.Style["display"= treeListView.ExpendDepth >= Convert.ToInt32(dr["TreeListView$Row$Depth"]) ? "block" : "none";
                        }

                    }

                }

                
            }


            
    获取Tree的图片

    Js代码实现折叠效果

    Code
  • 相关阅读:
    PZISP自动下载软件运行时出现“应用程序无法启动,因为应用程序的并行配置不正确”
    分析Memcached客户端如何把缓存数据分布到多个服务器上
    WebApi参数传递总结
    [NHibernate]一对多关系(级联删除,级联添加)
    提高SQL查询效率
    jquery validate 详解
    Winform子窗体刷新父窗体
    Windows如何修改MySQL用户root密码
    MySQL 5.6 for Windows 解压缩版配置安装
    获取地图文档(*.mxd)中比例尺问题
  • 原文地址:https://www.cnblogs.com/wschacker/p/1250446.html
Copyright © 2011-2022 走看看