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()); }
public static String BuildActionsMenu(ActionContainerHolder actions, 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"; } if (actions.Menu.Items.Count > 0) { result.AppendFormat("<div class='{0}'>", ClassName); Helpers.ContentHelper.ObjectActions = new List <MenuAction>(); var menuItems = Helpers.GetMenuActions(actions.Menu); /// Reversing for pull-right correct visibility if (!IsLeft) { menuItems = menuItems.Reverse().ToList(); } foreach (XafMenuItem menuItem in menuItems) { var action = (menuItem.ActionProcessor as MenuActionItemBase).Action as ActionBase; bool usePostBack = action.Model.GetValue <bool>("IsPostBackRequired"); if (!(Helpers.GenerateSingleChoiceAction(ref result, menuItem, IsLeft, style, callbackName, type, ClickScript))) { result.Append(Helpers.GetFormattedActionString(menuItem, ClickScript + ";" + Helpers.ContentHelper.GetScript(callbackName, String.Format("\"Action={0}\"", menuItem.Name), menuItem, usePostBack).Replace("'", "\""), style, type, Glyphicon)); } } result.Append("</div>"); } return(result.ToString()); }