Пример #1
0
        /// <summary>
        /// 对默认按钮赋默认值
        /// </summary>
        /// <param name="btn"></param>
        /// <param name="actionType"></param>
        static void SetButton(OpButtonInfo btn, ActionType actionType)
        {
            var b      = btn.Buttons.FirstOrDefault(o => o.ActionType == actionType); //传入
            var btnDef = Buttons.FirstOrDefault(o => o.ActionType == actionType);     //默认

            if (b == null)
            {
                btn.Buttons.Add(btnDef);
            }
            else
            {
                if (b.OnClick.IsNullOrEmpty())
                {
                    b.OnClick = btnDef.OnClick;
                }
                if (b.Text.IsNullOrEmpty())
                {
                    b.Text = btnDef.Text;
                }
                if (b.IconCls.IsNullOrEmpty())
                {
                    b.IconCls = btnDef.IconCls;
                }
                if (b.Sort > 0)
                {
                    b.Sort = btnDef.Sort;
                }
                b.Type = ButtonType.Normal;
            }
        }
Пример #2
0
 /// <summary>
 /// 设置/获取工具栏基本按钮信息
 /// </summary>
 /// <param name="viewData"></param>
 /// <param name="info"></param>
 /// <returns></returns>
 public static OpButtonInfo OpBtnInfos(this ViewDataDictionary viewData, OpButtonInfo info = null)
 {
     if (info == null)
     {
         var btn = viewData["opbtnInfos"] as OpButtonInfo;
         if (btn != null)
         {
             if (btn.Buttons == null)
             {
                 btn.Buttons = Buttons;
             }
             else
             {
                 SetButton(btn, ActionType.Add);
                 SetButton(btn, ActionType.Delete);
                 SetButton(btn, ActionType.Edit);
             }
         }
         return(btn);
     }
     viewData["opbtnInfos"] = info;
     return(null);
 }