示例#1
0
        public static String BuildActionsMenu(XbActionContainerHolder actionHolder, String callbackName, Boolean IsLeft = true, String style = "btn btn-primary btn-sm", String type = "button", String ClickScript = "", String ClassName = "actions", String Glyphicon = "glyphicon-star")
        {
            StringBuilder result = new StringBuilder();

            if (!IsLeft)
            {
                style += " pull-right";
            }
            else
            {
                style += " pull-left";
            }

            var actions = actionHolder.actionObjects.Where(f => f.Key.Active && f.Value.IsVisible && f.Value.Action.Active && f.Value.Action.Enabled).Select(f => f.Value.MenuItem).OrderBy(f => f.VisibleIndex).ToList();

            if (actions.Count > 0)
            {
                result.AppendFormat("<div class='{0}'>", ClassName);

                Helpers.ContentHelper.ObjectActions = new List <MenuAction>();

                /// Reversing for pull-right correct visibility
                if (!IsLeft)
                {
                    actions.Reverse();
                }

                foreach (XafMenuItem menuItem in actions)
                {
                    var action = (menuItem.ActionProcessor as MenuActionItemBase).Action as ActionBase;
                    var gIcon  = String.Concat(action.Model.GetValue <String>("Glyphicon"));
                    if (gIcon == "")
                    {
                        gIcon = Glyphicon;
                    }

                    bool usePostBack = action.Model.GetValue <bool>("IsPostBackRequired");
                    if (!(Helpers.GenerateSingleChoiceAction(ref result, menuItem, IsLeft, style, callbackName, type, ClickScript, gIcon)))
                    {
                        result.Append(Helpers.GetFormattedActionString(menuItem, ClickScript + ";" + Helpers.ContentHelper.GetScript(callbackName, String.Format("\"Action={0}\"", menuItem.Name), "", usePostBack).Replace("'", "\""), style, type, gIcon));
                    }
                }
                result.Append("</div>");
            }

            return(result.ToString());
        }
示例#2
0
 public static IList <XafMenuItem> GetMenuActions(XbActionContainerHolder holder)
 {
     return(holder.actionObjects.Where(f => f.Key.Active && f.Key.Enabled).Select(f => f.Value.MenuItem).ToList());
 }