Beispiel #1
0
        public List <MEasyuiTree> GetCompanySubjectsForTree()
        {
            MEasyuiTree     root     = new MEasyuiTree();
            List <MSubject> subjects = GetSubjectsForCompany();

            MSubject[] sArr = subjects.Where(s => !s.ParentSubjectCode.HasValue).ToArray();

            this.BuildSubjectTree(sArr, root, subjects.ToArray());

            return(root.children);
        }
Beispiel #2
0
        private MEasyuiTree BuildSubjectTree(MSubject[] subjects, MEasyuiTree tree, MSubject[] source)
        {
            foreach (MSubject s in subjects)
            {
                MEasyuiTree node = new MEasyuiTree();
                node.id    = s.SubjectCode;
                node.text  = string.Format("{0} {1}", s.SubjectCode, s.SubjectName);
                node.state = "open";
                tree.children.Add(node);

                MSubject[] sArr = source.Where(src => src.ParentSubjectCode == s.SubjectCode).ToArray();
                if (sArr.Length > 0)
                {
                    BuildSubjectTree(sArr, node, source);
                }
            }

            return(tree);
        }