예제 #1
0
        private void RefreshTree(bool saveExpandedState)
        {
            Guid?instanceId = null;

            if (Entity.HierarchyStartLevel == EntityLevel.Instance)
            {
                instanceId = this.SelectedInstanceId;
            }

            Tree.DataSource = EntityNodeProvider.GetEntityNodesTree(UserContext.Current.OrganizationId, instanceId, this.Entity.Id, this.Entity.Name);
            Tree.Rebind(saveExpandedState);

            if (Tree.Nodes.Count > 0)
            {
                Tree.Nodes[0].Expanded = true;
            }

            Tree.ContextMenus.Clear();
            Tree.ContextMenus.AddRange(this.ContextMenus.Values);
        }
예제 #2
0
        public void LoadTree()
        {
            if (EntityId != Guid.Empty && UserContext.Current != null)
            {
                Entity entity     = EntityFieldProvider.Entities[EntityId.ToString()];
                Guid?  instanceId = new Guid?();
                if (entity.HierarchyStartLevel == EntityLevel.Instance)
                {
                    instanceId = new Guid?(UserContext.Current.InstanceId);
                }
                ClientDataSet.EntityNodeDataTable dt = new ClientDataSet.EntityNodeDataTable();
                if (UserContext.Current != null)
                {
                    this.OnClientNodeClicked = "onClientNodeClicked";
                    //                    this.ContextMenus.AddRange(CustomContextMenus.Values);
                    base.DataFieldID       = dt.EntityNodeIdColumn.ColumnName;
                    base.DataFieldParentID = dt.ParentEntityNodeIdColumn.ColumnName;
                    base.DataTextField     = dt.NameColumn.ColumnName;
                    base.DataValueField    = dt.EntityNodeIdColumn.ColumnName;
                    this.DataSource        = EntityNodeProvider.GetEntityNodesTree(UserContext.Current.OrganizationId, instanceId, EntityId, entity.Name);
                    this.DataBind();
                    if (this.Nodes.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(CustomRootNodeText))
                        {
                            this.Nodes[0].Text = CustomRootNodeText;
                        }

                        if ((AllowRootNodeSelection.HasValue && !AllowRootNodeSelection.Value) || (!AllowRootNodeSelection.HasValue && !Entity.EnableRootNodeSelection))
                        {
                            this.Nodes[0].Checkable = false;
                            this.Nodes[0].Category  = "3";
                        }
                        this.Nodes[0].Expanded = true;
                    }
                }
            }

            ClientDataSet.EntityNodesRelatedEntityNodesDataTable t = EntityNodeProvider.GetAllEntityNodesRelatedEntityNodes(UserContext.Current.OrganizationId, EntityNodeId, EntityId);
            RadTreeNode rtn;

            foreach (ClientDataSet.EntityNodesRelatedEntityNodesRow row in t.Rows)
            {
                rtn = this.FindNodeByValue(row.RelatedEntityNodeId.ToString());
                if (rtn == null)
                {
                    row.Delete();
                    continue;
                }
                if (rtn.Category != "3")
                {
                    if (row.RelationType == (int)RelationType.Checked)
                    {
                        rtn.Checked = true;
                    }
                    else if (row.RelationType == (int)RelationType.CheckedAndAllChildren)
                    {
                        rtn.Checked  = true;
                        rtn.Category = "1";
                    }
                    else if (row.RelationType == (int)RelationType.Blocked)
                    {
                        rtn.Checked  = true;
                        rtn.Category = "2";
                    }
                }
            }

            SetStateNode(this.Nodes[0]);
            ProcessNodes(this.Nodes[0]);

            if (OnLoaded != null)
            {
                OnLoaded(this, new EventArgs());
            }
        }