示例#1
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);
        }
示例#2
0
        protected void treeList_CustomDataCallback(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomDataCallbackEventArgs e)
        {
            ASPxTreeList        treeList = (ASPxTreeList)sender;
            List <TreeListNode> nodelist = treeList.GetSelectedNodes();
            //数据压缩
            List <ExtendCode> codelist = new List <ExtendCode>();

            foreach (TreeListNode node in nodelist)
            {
                ExtendCode detail = (ExtendCode)node.DataItem;
                codelist.Add(detail);
            }
            e.Result = JsonConvert.SerializeObject(codelist);
        }
示例#3
0
        //异步获取选中值
        protected void OnCallbackCompleteSC(object sender, CallbackEventArgs e)
        {
            string callback_data = e.Parameter.ToString();

            string[] data = callback_data.Split(',');

            List <DictionaryItem> detailist = _codedetaillist;
            List <DictionaryItem> list      = new List <DictionaryItem>();

            for (int i = 0; i < data.Length; i++)
            {
                int index = Int32.Parse(data[i]);
                if (index < detailist.Count)
                {
                    list.Add(detailist[index]);
                }
            }
            // 如果是Nav的时候,要做一个级联选择;其它就不做处理
            if (ModuleField.DisplayFormat == CommonField.Nav.ToString())
            {
                list = GetSubList(list);
            }

            List <ExtendCode> codelist = new List <ExtendCode>();

            //数据压缩
            foreach (DictionaryItem detail in list)
            {
                ExtendCode code = new ExtendCode();
                code.ExtendCodeCode = detail.DictionaryItemCode;
                code.ExtendCodeName = detail.DictionaryItemName;
                codelist.Add(code);
            }

            e.Result = JsonConvert.SerializeObject(codelist);
        }
示例#4
0
        public System.Web.UI.Control LoadGridView(string param, 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();
                extdlist.Add(extcode);
            }

            ASPxGridView gridview = new ASPxGridView();

            gridview.ClientInstanceName             = "gridview" + ModuleField.FieldID;
            gridview.KeyFieldName                   = "ExtendCodeID";
            gridview.SettingsBehavior.AllowDragDrop = false;
            gridview.SettingsBehavior.AllowGroup    = false;
            gridview.Settings.ShowFilterRow         = true;
            gridview.Settings.ShowFilterRowMenu     = true;

            GridViewCommandColumn headercol = new GridViewCommandColumn();

            headercol.ShowSelectCheckbox        = true;
            headercol.VisibleIndex              = 0;
            headercol.ClearFilterButton.Visible = true;
            ITemplate    template = headercol.HeaderTemplate;
            ASPxCheckBox checkbox = new ASPxCheckBox();

            GridViewDataTextColumn datacol1 = new GridViewDataTextColumn();

            datacol1.FieldName    = "ExtendCodeCode";
            datacol1.VisibleIndex = 1;
            GridViewDataTextColumn datacol2 = new GridViewDataTextColumn();

            datacol2.FieldName    = "ExtendCodeName";
            datacol2.VisibleIndex = 2;

            gridview.Columns.Add(headercol);
            gridview.Columns.Add(datacol1);
            gridview.Columns.Add(datacol2);
            panel.Controls.Add(gridview);

            gridview.DataSource = extdlist;
            gridview.DataBind();
            return(panel);
        }