public static void InsertNode(ASPxTreeList treeList, ASPxDataInsertingEventArgs e)
    {
        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        AddNewNodeId(e.NewValues, docum);

        var     parentNodeInTreeList = treeList.FindNodeByKeyValue(treeList.NewNodeParentKey);
        var     parentID             = parentNodeInTreeList.GetValue("Id").ToString();
        XmlNode parentNode           = FindNode(docum, parentID);

        var     level   = Convert.ToInt32(parentNode.Attributes["Level"].Value) + 1;
        XmlNode newNode = docum.CreateElement("Level" + level + "Node");

        foreach (DictionaryEntry entry in e.NewValues)
        {
            newNode.Attributes.Append(GetNewAttribute(docum, entry.Key, entry.Value));
        }

        newNode.Attributes.Append(GetNewAttribute(docum, "Level", level));
        newNode.Attributes.Append(GetNewAttribute(docum, "ParentKey", parentID));

        parentNode.AppendChild(newNode);
        RearrangeAndSaveXml(docum);
    }
Пример #2
0
        protected void trvEmpleados_CustomCallback(object sender, TreeListCustomCallbackEventArgs e)
        {
            string strKey = "";
            List <TreeListNode> lstSelectedNodes = trlEmpresaRep.GetSelectedNodes();

            foreach (TreeListNode Node in lstSelectedNodes)
            {
                strKey += Node.Key + ",";
            }
            strKey = strKey.Substring(0, strKey.Length - 1);
            Session["DepartamentoSelected"] = strKey;
            DataTable dtbEmpleados = (DataTable)Session[Constantes.SesionTblEmpleadosSm];
            String    strFilter    = Constantes.ColumnaEmpleadoDefaultDepId + " in (" + strKey + ")";

            DataRow[] dtrFilter = dtbEmpleados.Select(strFilter);
            DataTable dtbFilter = dtbEmpleados.Clone();

            foreach (DataRow row in dtrFilter)
            {
                dtbFilter.ImportRow(row);
            }
            Session[Constantes.SesionTblEmpleadosSm1] = dtbFilter;
            ASPxTreeList treeList = (sender as ASPxTreeList);

            treeList.DataSource = dtbFilter;
            treeList.DataBind();
            treeList.ExpandAll();
        }
Пример #3
0
        private DataTable NavigatorBuildDataTable(object selTreeList)
        {
            ASPxTreeList tree = (ASPxTreeList)selTreeList;
            DataTable    dt   = new DataTable();

            string[]      fieldValues            = new string[5];
            List <string> fieldValuesID          = new List <string>();
            List <string> fieldValuesDisplayText = new List <string>();
            List <string> fieldValuesOrderNum    = new List <string>();
            List <string> fieldValuesParentID    = new List <string>();
            List <string> fieldValuesPageLink    = new List <string>();

            dt.Columns.Add("ID");
            dt.Columns.Add("DisplayText");
            dt.Columns.Add("OrderNum");
            dt.Columns.Add("ParentID");
            dt.Columns.Add("PageLink");
            IEnumerable <TreeListNode> list = tree.GetAllNodes();

            foreach (TreeListNode node in list)
            {
                fieldValues[0] = node.GetValue("ID").ToString();
                fieldValues[1] = node.GetValue("DisplayText").ToString();
                fieldValues[2] = node.GetValue("OrderNum").ToString();
                fieldValues[3] = node.GetValue("ParentID").ToString();
                fieldValues[4] = node.GetValue("PageLink").ToString();
                dt.Rows.Add(fieldValues);
            }
            return(dt);
        }
Пример #4
0
    protected void tlData_Init(object sender, EventArgs e)
    {
        ASPxTreeList treeList = sender as ASPxTreeList;

        treeList.DataSource = GetData();
        treeList.DataBind();
    }
Пример #5
0
        protected void tlSitemap_Init(object sender, EventArgs e)
        {
            ASPxTreeList treeList = sender as ASPxTreeList;
            object       keyValue = GetMasterRowKeyValue(treeList);

            treeList.RootValue = keyValue;
        }
Пример #6
0
    protected void ASPxTreeList1_CustomCallback(object sender, TreeListCustomCallbackEventArgs e)
    {
        ASPxTreeList tree         = sender as ASPxTreeList;
        TreeListNode deletingNode = tree.FindNodeByKeyValue(e.Argument);

        DeleteNodeAndChildren(deletingNode, tree);
    }
Пример #7
0
        protected void treelistCurrency_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e)
        {
            try
            {
                ASPxTreeList tree = sender as ASPxTreeList;
                TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey);
                NAS.DAL.Accounting.Currency.Currency currency = node.DataItem as NAS.DAL.Accounting.Currency.Currency;

                if (currency != null)
                {
                    //Setting Description for node
                    if (e.Column.Name == "Description" && e.Level > 1)
                    {
                        e.Cell.Text = String.Format("1 {0} = {1} {2}",
                                                    currency.ParentCurrencyId.Name,
                                                    currency.NumRequired,
                                                    currency.Name);
                    }
                    else if (e.Column.Name == "Description" && e.Level == 1)
                    {
                        e.Cell.Text = String.Format("Là đơn vị cao nhất");
                    }

                    if (e.Column.FieldName == "NumRequired" && e.Level == 1)
                    {
                        e.Cell.Text = string.Empty;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #8
0
        protected void grdProductUnit_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e)
        {
            //Setting numberRequired
            ASPxTreeList tree = sender as ASPxTreeList;

            if (e.Column.FieldName == "NumRequired" && e.Level == 1)
            {
                e.Cell.Text = "";
            }

            //Setting Description for node
            if (e.Column.Name == "Description")
            {
                TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey);

                NAS.DAL.Nomenclature.Item.ItemUnit currentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.DataItem;
                if (e.Level > 1)
                {
                    NAS.DAL.Nomenclature.Item.ItemUnit parentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.ParentNode.DataItem;
                    e.Cell.Text = String.Format("1 {0} bao gồm {1} {2}",
                                                parentItem.UnitId.Name,
                                                currentItem.NumRequired,
                                                currentItem.UnitId.Name);
                }
                else
                {
                    e.Cell.Text = String.Format("{0} là đơn vị tính cao nhất",
                                                currentItem.UnitId.Name);
                }
            }
        }
Пример #9
0
        protected void tlSitemap_Load(object sender, EventArgs e)
        {
            try
            {
                ASPxTreeList detailView = (ASPxTreeList)sender;
                detailView.Load += new EventHandler(detailView_Load);

                var datasource = new[]
                {
                    new { OrganizationId = 1, ParentOrganizationId = 0, Id = "MS0001", name = "Trang Chủ", Description = "Trang chủ", Property = "" },
                    new { OrganizationId = 2, ParentOrganizationId = 1, Id = "MS0002", name = "Tổ chức", Description = "Tổ chức", Property = "123456879" },
                    new { OrganizationId = 3, ParentOrganizationId = 2, Id = "MS0003", name = "Người dùng", Description = "Người sử dụng trong tổ chức", Property = "" },
                    new { OrganizationId = 4, ParentOrganizationId = 3, Id = "MS0004", name = "Danh mục", Description = "Danh mục", Property = "" },
                    new { OrganizationId = 5, ParentOrganizationId = 3, Id = "MS0005", name = "Mời", Description = "Mời", Property = "" },
                    new { OrganizationId = 6, ParentOrganizationId = 5, Id = "MS0006", name = "Mời qua email", Description = "Mời người sử dụng", Property = "" },
                    new { OrganizationId = 7, ParentOrganizationId = 5, Id = "MS0007", name = "Mời theo danh sách file", Description = "Mời theo danh sách file", Property = "" },
                    new { OrganizationId = 8, ParentOrganizationId = 1, Id = "MS0008", name = "MailServer", Description = "MailServer", Property = "" },
                    new { OrganizationId = 9, ParentOrganizationId = 0, Id = "MS0009", name = "Nghiệp vụ mua", Description = "Nghiệp vụ mua", Property = "" },
                    new { OrganizationId = 10, ParentOrganizationId = 0, Id = "MS00010", name = "Nghiệp vụ bán", Description = "Nghiệp vụ bán", Property = "" },
                    new { OrganizationId = 11, ParentOrganizationId = 0, Id = "MS0011", name = "Cấu hình Dữ liệu", Description = "Cấu hình Dữ liệu", Property = "" },
                    new { OrganizationId = 12, ParentOrganizationId = 11, Id = "MS0012", name = "OperationDB", Description = "OperationDB", Property = "" },
                    new { OrganizationId = 13, ParentOrganizationId = 11, Id = "MS0023", name = "Warehouse", Description = "Warehouse", Property = "" },
                    new { OrganizationId = 14, ParentOrganizationId = 11, Id = "MS0014", name = "Analytic Services", Description = "Analytic Services", Property = "" },
                    new { OrganizationId = 15, ParentOrganizationId = 11, Id = "MS0015", name = "FileServer", Description = "FileServer", Property = "" },
                    new { OrganizationId = 16, ParentOrganizationId = 11, Id = "MS0016", name = "Search Services", Description = "Search Services", Property = "" },
                };
                detailView.DataSource = datasource;
            }
            catch (Exception) { }
        }
Пример #10
0
        protected void SelectTree(ASPxTreeList treelist, DataTable dtSel)
        {
            TreeListNodeIterator iterator = treelist.CreateNodeIterator();
            TreeListNode         node;

            for (int i = 0; i < dtSel.Rows.Count; i++)
            {
                while (true)
                {
                    node = iterator.GetNext();
                    if (node == null)
                    {
                        break;
                    }

                    if ((Convert.ToInt32(dtSel.Rows[i]["ID"]) == Convert.ToInt32(node.GetValue("ID"))))
                    {
                        //5/8/2014 NS modified
                        if (node.ParentNode.Key != "" || !node.HasChildren)
                        {
                            node.Selected = true;
                        }
                    }
                }
                iterator.Reset();
            }
        }
    protected void ASPxTreeList1_CustomCallback(object sender, TreeListCustomCallbackEventArgs e)
    {
        ASPxTreeList treeList = (ASPxTreeList)sender;

        treeList.UpdateEdit();

        string[] data = e.Argument.Split(new char[] { '|' });
        treeList.FindNodeByKeyValue(data[0]).Focus();
        for (int i = 0; i < treeList.Columns.Count; i++)
        {
            TreeListDataColumn column = (TreeListDataColumn)treeList.Columns[i];
            if (column != null)
            {
                if (column.FieldName != data[1])
                {
                    column.EditCellTemplate = new MyTemplate();
                }
                else
                {
                    Session["column"]       = column.FieldName;
                    column.EditCellTemplate = null;
                }
            }
        }
        treeList.StartEdit(data[0]);
    }
Пример #12
0
        protected void treelistCurrency_CellEditorInitialize(object sender, DevExpress.Web.ASPxTreeList.TreeListColumnEditorEventArgs e)
        {
            ASPxTreeList treelistCurrency = sender as ASPxTreeList;

            if (e.Column.FieldName.Equals("NumRequired") && !treelistCurrency.IsNewNodeEditing)
            {
                TreeListNode node = treelistCurrency.FindNodeByKeyValue(e.NodeKey);
                if (node.Level == 1)
                {
                    ASPxTextEdit txtEdit = (ASPxTextEdit)e.Editor;
                    txtEdit.ReadOnly = true;
                }
            }

            if (e.Column.FieldName.Equals("NumRequired") && treelistCurrency.IsNewNodeEditing &&
                treelistCurrency.NewNodeParentKey == treelistCurrency.RootNode.Key)
            {
                e.Editor.Value    = 1;
                e.Editor.ReadOnly = true;
            }


            if (e.Column.FieldName.Equals("NumRequired") && !treelistCurrency.IsNewNodeEditing)
            {
                e.Editor.Focus();
            }
        }
Пример #13
0
        protected void TLCurrency_OnInit(object sender, EventArgs e)
        {
            ASPxTreeList treeList = sender as ASPxTreeList;
            object       keyValue = GetMasterRowKeyValue(treeList);

            Session["SessionCurrencyTypeId"] = keyValue.ToString();
        }
Пример #14
0
        public static void Bind(ASPxTreeList tree, string path)
        {
            tree.ClearNodes();
            XmlElement root = Xml.SelectSingleNode(path) as XmlElement;

            BindCore(tree, tree.RootNode, root);
        }
Пример #15
0
        protected void trlItemUnit_OnInit(object sender, EventArgs e)
        {
            ASPxTreeList treeList = sender as ASPxTreeList;
            object       keyValue = GetMasterRowKeyValue(treeList);

            dsItemUnit.CriteriaParameters["ItemId"].DefaultValue = keyValue.ToString();
            treeList.DataBind();
        }
 protected void TreeList_DataBound(object sender, EventArgs e)
 {
     if (!IsCallback && !IsPostBack)
     {
         ASPxTreeList tree = sender as ASPxTreeList;
         tree.ExpandAll();
     }
 }
Пример #17
0
 void UpdateTreeListButtons(ASPxTreeList treeList)
 {
     if (treeList.FocusedNode != null)
     {
         TreeListNodeCollection siblingNodes = (treeList.FocusedNode.ParentNode == null) ? treeList.Nodes : treeList.FocusedNode.ParentNode.ChildNodes;
         treeList.JSProperties["cpbtMoveUp_Enabled"]   = !((int)treeList.FocusedNode.GetValue("SortIndex") == 0);
         treeList.JSProperties["cpbtMoveDown_Enabled"] = !((int)treeList.FocusedNode.GetValue("SortIndex") == (siblingNodes.Count - 1));
     }
 }
        protected override void OnDeactivated()
        {
            if (treeList != null)
            {
                treeList = null;
            }

            base.OnDeactivated();
        }
Пример #19
0
 protected override void OnDeactivated()
 {
     base.OnDeactivated();
     if (treeList != null)
     {
         treeList.HtmlDataCellPrepared -= treeList_HtmlDataCellPrepared;
         treeList = null;
     }
 }
Пример #20
0
 static void BindCore(ASPxTreeList tree, TreeListNode node, XmlElement xmlNode)
 {
     node.SetValue("Text", xmlNode.Attributes["Text"].Value);
     foreach (XmlElement element in xmlNode.ChildNodes)
     {
         TreeListNode child = tree.AppendNode(element.GetAttribute("LinkId"), node);
         BindCore(tree, child, element);
     }
 }
Пример #21
0
    protected void tlData_HtmlRowPrepared(object sender, TreeListHtmlRowEventArgs e)
    {
        ASPxTreeList treeList = sender as ASPxTreeList;

        if (e.RowKind == TreeListRowKind.Data)
        {
            TreeListNode parent = treeList.FindNodeByKeyValue(e.NodeKey).ParentNode;
            e.Row.Attributes.Add("nodeParent", (parent == null) ? String.Empty : parent.Key);
        }
    }
    protected void ASPxTreeList1_Init(object sender, EventArgs e)
    {
        ASPxTreeList treeList = sender as ASPxTreeList;
        object       keyValue = ASPxGridView.GetDetailRowKeyValue(treeList);

        if (keyValue.Equals(2) || keyValue.Equals(5))
        {
            treeList.RootValue = keyValue;
        }
    }
Пример #23
0
    void OnCommand(object sender, CommandEventArgs e)
    {
        Control      control   = sender as Control;
        Page         page      = control.Page;
        Label        infoLabel = page.FindControl("lblInfo") as Label;
        ASPxTreeList treeList  = page.FindControl("tree") as ASPxTreeList;
        TreeListNode node      = treeList.FindNodeByKeyValue(e.CommandArgument.ToString());

        infoLabel.Text = string.Format("Budget of <b>{0}</b> is <b>{1:C}</b>", node["Department"], node["Budget"]);
    }
Пример #24
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            ASPxTreeListEditor treeListEditor = View.Editor as ASPxTreeListEditor;

            if (treeListEditor != null)
            {
                treeList = treeListEditor.TreeList;
                treeList.HtmlDataCellPrepared += treeList_HtmlDataCellPrepared;
            }
        }
Пример #25
0
        public static TreeListNode GetParentNode(this ASPxTreeList source, string childNodeKey)
        {
            if (childNodeKey == null)
            {
                return(null);
            }

            var childNode = source.FindNodeByKeyValue(childNodeKey);

            return(childNode != null ? childNode.ParentNode : null);
        }
Пример #26
0
        public static T GetParentItem <T>(this ASPxTreeList source, string childNodeKey)
        {
            var parentNode = source.GetParentNode(childNodeKey);

            if (parentNode == source.RootNode)
            {
                return(default(T));
            }

            return((T)(parentNode != null ? parentNode.DataItem : null));
        }
    protected void TreeList_CustomJSProperties(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomJSPropertiesEventArgs e)
    {
        ASPxTreeList tree          = sender as ASPxTreeList;
        Hashtable    employeeNames = new Hashtable();

        foreach (TreeListNode node in tree.GetVisibleNodes())
        {
            employeeNames.Add(node.Key, node["FirstName"] + " " + node["LastName"]);
        }
        e.Properties["cpEmployeeNames"] = employeeNames;
    }
Пример #28
0
        // 初始加载treelist
        public System.Web.UI.Control LoadTreeList(string target)
        {
            ASPxPanel     panel        = new ASPxPanel();
            string        _targetTable = GetTargetTableName((int)ModuleField.FieldType);
            StringBuilder sql          = new StringBuilder();

            if (target == "Dictionary")
            {
                sql.Append("select * from DictionaryItem where 1=1");
                sql.Append(" and DictionaryItemCode like '" + ModuleField.CodeCat + "%'");
            }
            else
            {
                sql.Append("select * from " + _targetTable + " where 1=1");
            }
            DataSet           userset  = SqlHelper.GetDataBySQL(sql.ToString(), _targetTable);
            List <ExtendCode> extdlist = new List <ExtendCode>();

            for (int i = 0; i < userset.Tables[0].Rows.Count; i++)
            {
                DataRow    dr      = userset.Tables[0].Rows[i];
                ExtendCode extcode = new ExtendCode();
                extcode.ExtendCodeID   = Convert.ToInt32(dr.ItemArray[0].ToString());
                extcode.ExtendCodeCode = dr.ItemArray[1].ToString();
                extcode.ExtendCodeName = dr.ItemArray[2].ToString();
                extcode.ParentID       = Convert.ToInt32(dr.ItemArray[5].ToString());
                extdlist.Add(extcode);
            }

            ASPxTreeList treelist = new ASPxTreeList();

            treelist.ClientInstanceName               = "treelist" + ModuleField.FieldID;
            treelist.KeyFieldName                     = "ExtendCodeID";
            treelist.ParentFieldName                  = "ParentID";
            treelist.SettingsSelection.Enabled        = true;
            treelist.SettingsSelection.Recursive      = true;
            treelist.SettingsSelection.AllowSelectAll = true;

            treelist.CustomDataCallback += new TreeListCustomDataCallbackEventHandler(treeList_CustomDataCallback); //treelist.GetSelectedNodes();
            treelist.ClientSideEvents.CustomDataCallback = "function(s, e) { CustomDataCallbackComplete(e," + ModuleField.FieldID + ");}";

            TreeListDataColumn datacol = new TreeListDataColumn();

            datacol.FieldName    = "ExtendCodeName";
            datacol.VisibleIndex = 0;
            treelist.SettingsBehavior.ExpandCollapseAction = TreeListExpandCollapseAction.NodeDblClick;
            treelist.Columns.Add(datacol);
            panel.Controls.Add(treelist);

            treelist.DataSource = extdlist;
            treelist.DataBound += new EventHandler(treeList_DataBound);//treelist.DataBind();

            return(panel);
        }
Пример #29
0
 private void DeleteNodeAndChildren(TreeListNode deletingNode, ASPxTreeList tree)
 {
     if (deletingNode.HasChildren)
     {
         foreach (TreeListNode child in deletingNode.ChildNodes)
         {
             DeleteNodeAndChildren(child, tree);
         }
     }
     //tree.DeleteNode(deletingNode.Key); //Uncoment this line to allow node deleting
 }
    public static void DragAndDropNode(ASPxTreeList treeList, TreeListNodeDragEventArgs e)
    {
        XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource;
        XmlDocument   docum         = xmlDataXource.GetXmlDocument();

        XmlNode oldChildNode = FindNode(docum, e.Node.GetValue("Id"));
        XmlNode parentNode   = FindNode(docum, e.NewParentNode.GetValue("Id"));

        ReplaceNode(docum, parentNode, oldChildNode);
        RearrangeAndSaveXml(docum);
    }
Пример #31
0
 void ProcessNodes(TreeListNode startNode, ASPxTreeList list)
 {
     if (startNode == null) return;
     TreeListNodeIterator iterator = new TreeListNodeIterator(startNode);
     while (iterator.Current != null)
     {
         GetParentNodeKey(iterator.Current, list);
         iterator.GetNext();
     }
 }
Пример #32
0
 private void CreateColoms(ASPxTreeList tl, List<string> coloms)
 {
     for (var i = 0; i < coloms.Count; i++)
     {
         var c = new TreeListDataColumn(coloms[i]);
         tl.Columns.Add(c);
     }
 }
Пример #33
0
    private static void SelectChildren(ASPxTreeList tree, TreeListNode node, bool newState)
    {
        // TreeListNode node = tree.FindNodeByKeyValue(nodeKey);
        //node.AllowSelect = true;
        node.Selected = newState;

        if (!node.HasChildren)
        {
            return;
        }
        foreach (TreeListNode item in node.ChildNodes)
        {
            SelectChildren(tree, node, newState);
        }
    }
Пример #34
0
    public static void BindData(ASPxTreeList treelist, DevExpress.Xpo.Session s, string objectname, string filter = "", params object[] parameter)
    {
        try
        {
            DynamicDataTableClassInfo classInfo = dynamicClasses[objectname];

            if (classInfo != null)
            {
                XPServerCollectionSource ds = new XPServerCollectionSource(s, dynamicClasses[objectname], CriteriaOperator.Parse(filter, parameter));
                treelist.DataSource = ds;
                //treelist.KeyFieldName = classInfo.KeyProperty.DisplayName;
            }
            else
                throw new Exception(string.Format("Đối tượng {0} không tìm thấy trong database. Nếu không có dữ liệu hiển thị thì XPOProfiles để xem điều kiện lọc đúng chưa", objectname));
        }
        catch (Exception ex)
        {
            SiAuto.Main.LogColored(Color.Red, "Loi BindData:" + ex.ToString());
            throw ex;
        }
    }
Пример #35
0
 public void AddTreeExporter(ASPxTreeList tree)
 {
     treeExporter.ID = "treeExporter";
     treeExporter.TreeListID = tree.ID;
     treeExporter.DataBind();
     this.Controls.Add(treeExporter);
 }