Пример #1
0
        public void ListDataToRadTree(DataTable tableSource, string parentField, RadTreeView treeView, string parentValue)
        {
            string      strItemNo   = "";
            string      strItemName = "";
            string      strurl      = "";
            string      strParentNo = "";
            RadTreeNode objMidNode  = null;

            treeView.Nodes.Clear();
            for (int intIndex = 0; intIndex < tableSource.Rows.Count; intIndex++)
            {
                strItemNo   = tableSource.Rows[intIndex]["itemno"].ToString();
                strItemName = tableSource.Rows[intIndex]["itemname"].ToString();
                strurl      = tableSource.Rows[intIndex]["URL"].ToString();
                strParentNo = tableSource.Rows[intIndex]["parentno"].ToString();

                if (tableSource.Rows[intIndex][parentField].ToString() == parentValue)
                {
                    RadTreeNode objNode = new RadTreeNode(strItemName, strItemNo);
                    treeView.Nodes.Add(objNode);
                }
                else
                {
                    objMidNode = treeView.FindNodeByValue(strParentNo);
                    if (objMidNode != null)
                    {
                        objMidNode.Nodes.Add(new RadTreeNode(strItemName, strItemNo));
                    }
                }
            }
        }
        /// <summary>
        /// Binds the data.
        /// </summary>
        public void BindData()
        {
            rfvRequirementSeverityOfExposures.ErrorMessage = _validationErrorMessage;

            _radRequirementSeverityOfExposureTreeView = ((RadTreeView)radRequirementSeverityOfExposures.Items[0].FindControl("radRequirementSeverityOfExposureTreeView"));

            _radRequirementSeverityOfExposureTreeView.Nodes.Clear();

            if (ShowEmpty)
            {
                radRequirementSeverityOfExposures.EmptyMessage = EmptyItemText;
            }
            if (_validationGroup != String.Empty)
            {
                rfvRequirementSeverityOfExposures.ValidationGroup = _validationGroup;
                rfvRequirementSeverityOfExposures.Enabled         = true;
            }
            else
            {
                rfvRequirementSeverityOfExposures.Enabled = false;
            }

            var requirementSeverityOfExposures = _dataManager.RequirementSeverityOfExposure.SelectHierarchy(CurrentUser.Instance.SiteID, RequirementTypeId);

            _radRequirementSeverityOfExposureTreeView.DataSource        = requirementSeverityOfExposures;
            _radRequirementSeverityOfExposureTreeView.DataTextField     = "Title";
            _radRequirementSeverityOfExposureTreeView.DataFieldID       = "ID";
            _radRequirementSeverityOfExposureTreeView.DataValueField    = "ID";
            _radRequirementSeverityOfExposureTreeView.DataFieldParentID = "ParentID";
            _radRequirementSeverityOfExposureTreeView.DataBind();

            if (_selectedCategoryId != Guid.Empty)
            {
                var selectedCategory = _dataManager.RequirementSeverityOfExposure.SelectById(_selectedCategoryId);

                radRequirementSeverityOfExposures.Items[0].Text  = selectedCategory.Title;
                radRequirementSeverityOfExposures.Items[0].Value = _selectedCategoryId.ToString();
                radRequirementSeverityOfExposures.SelectedValue  = _selectedCategoryId.ToString();

                RadTreeNode rtn = _radRequirementSeverityOfExposureTreeView.FindNodeByValue(_selectedCategoryId.ToString());
                rtn.Expanded = true;
                rtn.Selected = true;
                rtn.ExpandParentNodes();
            }
        }
Пример #3
0
        public void ListDataToRadTree(DataTable tableSource, string parentField, RadTreeView treeView, bool showTip)
        {
            string      strItemNo   = "";
            string      strItemName = "";
            string      strurl      = "";
            string      strParentNo = "";
            string      strTip      = "";
            RadTreeNode objMidNode  = null;

            treeView.Nodes.Clear();
            for (int intIndex = 0; intIndex < tableSource.Rows.Count; intIndex++)
            {
                strItemNo   = tableSource.Rows[intIndex]["itemno"].ToString();
                strItemName = tableSource.Rows[intIndex]["itemname"].ToString();
                strurl      = tableSource.Rows[intIndex]["URL"].ToString();
                strParentNo = tableSource.Rows[intIndex]["parentno"].ToString();
                strTip      = "No:" + strItemNo + System.Environment.NewLine;
                strTip     += "Name:" + strItemName + System.Environment.NewLine;
                strTip     += "url:" + strurl;

                if (tableSource.Rows[intIndex][parentField].ToString() == "0")
                {
                    RadTreeNode objNode = new RadTreeNode(strItemName, strItemNo);
                    if (showTip)
                    {
                        objNode.ToolTip = strTip;
                    }
                    treeView.Nodes.Add(objNode);
                }
                else
                {
                    objMidNode = treeView.FindNodeByValue(strParentNo);
                    if (objMidNode != null)
                    {
                        RadTreeNode objsubNode = new RadTreeNode(strItemName, strItemNo);
                        if (showTip)
                        {
                            objsubNode.ToolTip = strTip;
                        }
                        objMidNode.Nodes.Add(objsubNode);
                    }
                }
            }
        }
 /// <summary>
 /// 设置选中的值
 /// </summary>
 /// <param name="treeview"></param>
 /// <param name="values">值</param>
 public static RadTreeView SetChecked(this RadTreeView treeview, string values)
 {
     if (!string.IsNullOrEmpty(values))
     {
         string[] valueArray = values.SplitNonEmpty();
         if (values != null && values.Length > 0)
         {
             foreach (string value in valueArray)
             {
                 RadTreeNode node = treeview.FindNodeByValue(value);
                 if (node != null && node.Nodes.Count == 0)
                 {
                     node.Checked = true;
                 }
             }
         }
     }
     return(treeview);
 }
Пример #5
0
 public void setSelectedNode(string NodeValue)
 {
     _Tree.FindNodeByValue(NodeValue).Selected = true;
 }
Пример #6
0
        /// <summary>
        /// Raises the webpart Onload event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            //  base.OnLoad(e);
            EnsureChildControls();
            try
            {
                pnlWellBookTreeView = new Panel();
                pnlWellBookTreeView.ID = "Panel1";
                this.Controls.Add(pnlWellBookTreeView);

                trvWellBookViewer = new RadTreeView();
                trvWellBookViewer.ID = "RadTreeView1";
                trvWellBookViewer.CheckBoxes = true;
              //  if (this.Page.Request.Params[EVENTTARGET] == null || (!this.Page.Request.Params[EVENTTARGET].ToLowerInvariant().Equals("customisechaptersinsession")))
             //       {
                    LoadRootNodes(trvWellBookViewer, TreeNodeExpandMode.ServerSideCallBack);
               // }

                    trvWellBookViewer.NodeExpand += new RadTreeViewEventHandler(treeView_NodeExpand);
                    trvWellBookViewer.NodeClick += new RadTreeViewEventHandler(treeView_NodeClick);
                    trvWellBookViewer.CheckAllNodes();
                    trvWellBookViewer.TriStateCheckBoxes = true;
                    trvWellBookViewer.CheckChildNodes = true;

                pnlWellBookTreeView.Controls.Add(trvWellBookViewer);
                this.Controls.Add(pnlWellBookTreeView);
                if (!Page.IsPostBack)
                {
                    objTreeNodeValues = new TreeNodeSelection();
                    if (trvWellBookViewer != null)
                    {
                        if (trvWellBookViewer.FindNodeByValue(HttpContext.Current.Request.QueryString[QUERYSTRING_BOOKID]) != null)
                        {
                            trvWellBookViewer.FindNodeByValue(HttpContext.Current.Request.QueryString[QUERYSTRING_BOOKID]).Selected = true;
                        }
                        if (trvWellBookViewer.SelectedNode != null && (trvWellBookViewer.SelectedNode.Level == 0 || trvWellBookViewer.SelectedNode.Level == 1))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETAB_JS_KEY, HIDETAB_JS);
                        }
                    }
                    objTreeNodeValues.IsBookSelected = true;
                    objTreeNodeValues.BookID = HttpContext.Current.Request.QueryString[QUERYSTRING_BOOKID];
                    HttpContext.Current.Session[SESSION_WEBPARTPROPERTIES] = objTreeNodeValues;
                }
                ExpandChapterNode();
                this.Page.Title = WELLBOOK_VIEWER_TITLE;
            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(strParentSiteURL, webEx);
            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(strParentSiteURL, ex);
            }
        }
Пример #7
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        public void BindData()
        {
            _radProductCategoryTreeView = ((RadTreeView)radCategories.Items[0].FindControl("radProductCategoryTreeView"));

            _radProductCategoryTreeView.Nodes.Clear();

            if (ShowEmpty)
            {
                radCategories.EmptyMessage = EmptyItemText;
            }
            if (_validationGroup != String.Empty)
            {
                rfvCategories.ValidationGroup = _validationGroup;
                rfvCategories.Enabled         = true;
            }
            else
            {
                rfvCategories.Enabled = false;
            }

            var productCategories     = dataManager.ProductCategory.SelectHierarchy(SiteID).ToList();
            var publicationCategories = dataManager.PublicationCategory.SelectHierarchy(SiteID);

            if (SelectDefault && _selectedCategoryId == Guid.Empty)
            {
                switch (CategoryType)
                {
                case "Product":
                    SelectedCategoryId = productCategories.Where(pc => pc.IsDefault).Select(pc => pc.ID).FirstOrDefault();
                    break;

                case "Publication":
                    SelectedCategoryId = publicationCategories.Where(pc => pc.IsDefault).Select(pc => pc.ID).FirstOrDefault();
                    break;
                }
            }

            switch (CategoryType)
            {
            case "Product":
                _radProductCategoryTreeView.DataSource = productCategories;
                break;

            case "Publication":
                _radProductCategoryTreeView.DataSource = publicationCategories;
                break;
            }

            _radProductCategoryTreeView.DataTextField     = "Title";
            _radProductCategoryTreeView.DataFieldID       = "ID";
            _radProductCategoryTreeView.DataValueField    = "ID";
            _radProductCategoryTreeView.DataFieldParentID = "ParentID";
            _radProductCategoryTreeView.DataBind();

            if (_selectedCategoryId != Guid.Empty)
            {
                switch (CategoryType)
                {
                case "Product":
                    var selectedCategory = dataManager.ProductCategory.SelectById(_selectedCategoryId);
                    radCategories.Items[0].Text = selectedCategory.Title;
                    break;

                case "Publication":
                    var selectedCategory2 = dataManager.PublicationCategory.SelectById(_selectedCategoryId);
                    radCategories.Items[0].Text = selectedCategory2.Title;
                    break;
                }

                radCategories.Items[0].Value = _selectedCategoryId.ToString();

                radCategories.SelectedValue = _selectedCategoryId.ToString();

                RadTreeNode rtn = _radProductCategoryTreeView.FindNodeByValue(_selectedCategoryId.ToString());
                rtn.Expanded = true;
                rtn.Selected = true;
                rtn.ExpandParentNodes();
            }
        }