Exemplo n.º 1
0
        private CtrlBase GeneralEasyuiCtrl(Dictionary <string, object> ctrl)
        {
            string strCtrlType = ctrl.GetValue("CtrlType");

            if (string.IsNullOrEmpty(strCtrlType))
            {
                return(null);
            }

            string dataOptions = ctrl.GetValue("Detail");
            var    dOptionDic  = dataOptions.JsonToDictionary();
            var    styleDic    = new Dictionary <string, object>();
            var    classNames  = new List <string>();
            var    fieldName   = ctrl.GetValue("FieldName");

            if (!string.IsNullOrEmpty(dataOptions))
            {
                #region style
                List <string> dOptionKeyToRemove = new List <string>();
                foreach (var item in dOptionDic)
                {
                    if (item.Key.Contains("style"))
                    {
                        var tmp = item.Key.Split('_');
                        if (tmp.Length == 2)
                        {
                            styleDic.SetValue(tmp[1], item.Value);
                            dOptionKeyToRemove.Add(item.Key);
                        }
                    }
                }
                foreach (var item in dOptionKeyToRemove)
                {
                    dOptionDic.Remove(item);//如果是style 部分属性设置,则从dataoptions中移除
                }
                #endregion
                #region  class

                if (string.IsNullOrEmpty(ctrl.GetValue("IsVisible")) || ctrl.GetValue("IsVisible") != "是")
                {
                    dOptionDic.Add("visible", "false");
                }
                #endregion
                if (string.IsNullOrEmpty(ctrl.GetValue("Enable")) || ctrl.GetValue("Enable") != "是")
                {
                    dOptionDic.SetValue("disabled", true);
                }
            }
            EasyUICtrlPrepareData prepareData = new EasyUICtrlPrepareData()
            {
                ClassNames  = classNames,
                Style       = styleDic,
                DataOptions = dOptionDic
            };

            var easyUICtrl = EasyUICtrlFactory.GetCtrl(strCtrlType, fieldName, prepareData);
            return(easyUICtrl);
        }
Exemplo n.º 2
0
        private DataGrid GetDataGrid(ListConfig list)
        {
            var propertyDic = list.PropertySetting.JsonToDictionary();
            var style       = new Dictionary <string, object>();
            var dataOptions = new Dictionary <string, object>();

            EasyUICtrlPrepareData pData = new EasyUICtrlPrepareData()
            {
                Style       = style,
                DataOptions = dataOptions,
                Attr        = propertyDic
            };

            List <Dictionary <string, object> > collist = list.ColumnSetting.JsonToDictionaryList();
            DataGrid dg = new DataGrid("mf_grid", pData, collist);

            dg.Prepare();
            return(dg);
        }
Exemplo n.º 3
0
        private List <Button> GetButtonList(ListConfig list)
        {
            List <Button> buttonList    = new List <Button>();
            var           buttonDicList = list.GetButtonList();

            foreach (var buttonDic in buttonDicList)
            {
                var detailDic = buttonDic.GetValue("Detail").JsonToDictionary();
                var attr      = new Dictionary <string, object>();

                string title = buttonDic.GetValue("title");
                buttonDic.Remove("title");
                if (!string.IsNullOrEmpty(detailDic.GetValue("onclick")))
                {
                    if (!string.IsNullOrEmpty(detailDic.GetValue("mustSelect")))
                    {
                        string action = string.Format("checkSelection(\"{0}\",\"{1}\")", detailDic.GetValue("mustSelect"), detailDic.GetValue("onclick"));
                        buttonDic.SetValue("onclick", action);
                    }
                    else
                    {
                        buttonDic.SetValue("onclick", detailDic.GetValue("onclick"));
                    }
                }
                else if (!string.IsNullOrEmpty(buttonDic.GetValue("url")))
                {
                    string url = buttonDic.GetValue("url");
                    //高宽
                    string width  = detailDic.GetValue("width");
                    string height = detailDic.GetValue("height");

                    if (!string.IsNullOrEmpty(detailDic.GetValue("mustSelect")))
                    {
                        string clickCmd = "\"openWindowWithUrl(\\\"" + url + "\\\",\\\"" + width + "\\\",\\\"" + height + "\\\")\"";
                        string action   = string.Format("checkSelection(\"{0}\",{1})", detailDic.GetValue("mustSelect"), clickCmd);
                        buttonDic.SetValue("onclick", action);
                    }
                    else
                    {
                        string clickCmd = "openWindowWithUrl(\"" + url + "\")";
                        buttonDic.SetValue("onclick", clickCmd);
                    }
                    buttonDic.Remove("url");
                }

                var classNames = new List <string>();
                if (buttonDic.GetValue("hidden").ToLower() == "true")
                {
                    classNames.Add("euiCtrlHidden");
                }

                EasyUICtrlPrepareData pData = new EasyUICtrlPrepareData()
                {
                    Attr       = buttonDic,
                    ClassNames = classNames
                };
                Button dg = new Button(buttonDic.GetValue("id"), pData, title);
                dg.Prepare();
                buttonList.Add(dg);
            }

            return(buttonList);
        }