Example #1
0
        /// <summary>
        /// 加载树形数据
        /// </summary>
        /// <param name="tree"></param>
        public void Load(ArrayList tree)
        {
            //节点必须有idField
            if (tree == null)
            {
                tree = new ArrayList();
            }
            list     = TreeUtil.ToList(tree, "-1", nodesField, idField, pidField);
            dataview = null;

            //idField存储哈希,便于快速检索
            idMaps = new Hashtable();
            for (int i = list.Count - 1; i >= 0; i--)
            {
                Hashtable node = (Hashtable)list[i];
                idMaps[node[idField].ToString()] = node;
            }

            //遍历列表,生成leafField, levelField
            for (int i = list.Count - 1; i >= 0; i--)
            {
                Hashtable node  = (Hashtable)list[i];
                String    id    = node[idField].ToString();
                ArrayList nodes = (ArrayList)node[nodesField];
                node[leafField]  = (nodes == null || nodes.Count == 0) ? true : false;
                node[levelField] = GetAncestors(id).Count;
            }

            //清除折叠信息
            _collapseNodes = new ArrayList();
            DoExpandeds();

            //清除过滤信息
            filtered = null;
        }
Example #2
0
        /// <summary>
        /// 加载列表数据
        /// </summary>
        /// <param name="list"></param>
        public void LoadList(ArrayList list)
        {
            if (list == null)
            {
                list = new ArrayList();
            }
            ArrayList tree = TreeUtil.ToTree(list, nodesField, idField, pidField);

            Load(tree);
        }