private object CustomButton <TButton>( string name, string text, string url, string actionName, string controllerName, string routeName, object routeValues, bool ajax, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) where TButton : GridCustomCommandBase, new() { var command = new TButton(); command.ButtonType = buttonType; command.HtmlAttributes = htmlAttributes.ToDictionary(); command.ImageHtmlAttributes = imageHtmlAttributes.ToDictionary(); command.Text = text; command.Ajax = ajax; command.Name = name; if (url.HasValue()) { command.Url(url); } if (actionName.HasValue()) { command.Action(actionName, controllerName, routeValues); text = actionName; } if (routeName.HasValue()) { command.Route(routeName, routeValues); text = routeName; } if (string.IsNullOrEmpty(command.Text)) { command.Text = text; } var buttons = command.CreateDisplayButtons(Localization, UrlBuilder, new GridHtmlHelper <T>(ViewContext, DataKeyStore)); var fragment = new HtmlFragment(); buttons.Each(button => button.Create(null).AppendTo(fragment)); #if MVC3 return(MvcHtmlString.Create(fragment.ToString())); #else return(fragment.ToString()); #endif }
private object Button <TButton>(T dataItem, GridButtonType buttonType, object htmlAttributes) where TButton : GridActionCommandBase, new() { var command = new TButton(); command.ButtonType = buttonType; command.HtmlAttributes = htmlAttributes.ToDictionary(); var buttons = command.CreateDisplayButtons(Localization, UrlBuilder, new GridHtmlHelper <T>(ViewContext, DataKeyStore)); var fragment = new HtmlFragment(); buttons.Each(button => button.Create(dataItem).AppendTo(fragment)); #if MVC3 return(MvcHtmlString.Create(fragment.ToString())); #else return(fragment.ToString()); #endif }