public object SubmitChangesButton(GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { Editing.Enabled = true; RegisterEditingScriptFiles(); InitializeEditors(); return(Button <GridToolBarSubmitChangesCommand <T> >(null, buttonType, htmlAttributes, imageHtmlAttributes)); }
public ActionResult Insert(GridEditMode mode, GridButtonType type) { ViewData["mode"] = mode; ViewData["type"] = type; //Create a new instance of the EditableProduct class. EditableProduct product = new EditableProduct(); //Perform model binding (fill the product properties and validate it). if (TryUpdateModel(product)) { //The model is valid - insert the product and redisplay the grid. SessionProductRepository.Insert(product); //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. RouteValueDictionary routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); return RedirectToAction("EditingServerSide", routeValues); } //The model is invalid - render the current view to show any validation errors return View("EditingServerSide", SessionProductRepository.All()); }
public ActionResult Save(int id, GridEditMode mode, GridButtonType type) { ViewData["mode"] = mode; ViewData["type"] = type; //Create a new instance of the EditableProduct class and set its ProductID property. EditableProduct product = new EditableProduct { ProductID = id }; //Perform model binding (fill the product properties and validate it). if (TryUpdateModel(product)) { //The model is valid - update the product and redisplay the grid. SessionProductRepository.Update(product); //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. RouteValueDictionary routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); return(RedirectToAction("EditingServerSide", routeValues)); } //The model is invalid - render the current view to show any validation errors return(View("EditingServerSide", SessionProductRepository.All())); }
public object EditButton(T dataItem, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { Editing.Enabled = true; RegisterEditingScriptFiles(); return(Button <GridEditActionCommand>(dataItem, buttonType, htmlAttributes, imageHtmlAttributes)); }
private string DetermineCssClass(GridButtonType buttonType) { string buttonTypeCssClass = UIPrimitives.ButtonIconText; //TODO: Implement command button types //switch (buttonType) //{ // case GridButtonType.Image: // { // buttonTypeCssClass = UIPrimitives.ButtonIcon; // } // break; // case GridButtonType.ImageAndText: // { // buttonTypeCssClass = UIPrimitives.ButtonIconText; // } // break; // case GridButtonType.BareImage: // { // buttonTypeCssClass = string.Format("{0} {1}", UIPrimitives.ButtonIcon, UIPrimitives.ButtonBare); // } // break; // default: // return UIPrimitives.Button; //} return(string.Format("{0} {1}", UIPrimitives.Button, buttonTypeCssClass)); }
public ActionResult Delete(int id, GridEditMode mode, GridButtonType type) { //Find a product with ProductID equal to the id action parameter EditableProduct product = SessionProductRepository.One(p => p.ProductID == id); RouteValueDictionary routeValues; if (product == null) { //A product with the specified id does not exist - redisplay the grid //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); // add button type to the route values routeValues.Add("type", type); return(RedirectToAction("EditingServerSide", routeValues)); } //Delete the record SessionProductRepository.Delete(product); routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); // add button type to the route values routeValues.Add("type", type); //Redisplay the grid return(RedirectToAction("EditingServerSide", routeValues)); }
public ActionResult Delete(int id, GridEditMode mode, GridButtonType type) { //Find a product with ProductID equal to the id action parameter EditableProduct product = SessionProductRepository.One(p => p.ProductID == id); RouteValueDictionary routeValues; if (product == null) { //A product with the specified id does not exist - redisplay the grid //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); // add button type to the route values routeValues.Add("type", type); return RedirectToAction("EditingServerSide", routeValues); } //Delete the record SessionProductRepository.Delete(product); routeValues = this.GridRouteValues(); // add the editing mode to the route values routeValues.Add("mode", mode); // add button type to the route values routeValues.Add("type", type); //Redisplay the grid return RedirectToAction("EditingServerSide", routeValues); }
private string DetermineCssClass(GridButtonType buttonType) { string buttonTypeCssClass = ""; switch (buttonType) { case GridButtonType.Image: { buttonTypeCssClass = UIPrimitives.ButtonIcon; } break; case GridButtonType.ImageAndText: { buttonTypeCssClass = UIPrimitives.ButtonIconText; } break; case GridButtonType.BareImage: { buttonTypeCssClass = string.Format("{0} {1}", UIPrimitives.ButtonIcon, UIPrimitives.ButtonBare); } break; default: return(UIPrimitives.Button); } return(string.Format("{0} {1}", UIPrimitives.Button, buttonTypeCssClass)); }
/// <summary> /// Sets the button type. /// </summary> /// <param name="type">The button type.</param> /// <returns></returns> public TBuilder ButtonType(GridButtonType type) { Guard.IsNotNull(type, "type"); Command.ButtonType = type; return(this as TBuilder); }
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 }
public T CreateButton <T>(GridButtonType type) where T : IGridButtonBuilder, new() { var button = new T(); button.CssClass = DetermineCssClass(type); Decorate(button, type); return(button); }
public static string GetHTMLForButtonType(GridButtonType gridButtonType, ButtonIcon buttonIcon, string actionComplete = "#") { var htmlStr = string.Format( "<a class='{0}' href='{2}'>{1}</a>", GetClasses(gridButtonType, buttonIcon), GetInner(buttonIcon), actionComplete); return(htmlStr); }
private void Decorate(IGridButtonBuilder button, GridButtonType type) { if (type == GridButtonType.Image || type == GridButtonType.BareImage || type == GridButtonType.ImageAndText) { button.Decorators.Add(new GridButtonImageDecorator(button)); } if (type != GridButtonType.Image && type != GridButtonType.BareImage) { button.Decorators.Add(new GridButtonTextDecorator(button)); } }
private void Decorate(IGridButtonBuilder button, GridButtonType type) { //TODO: Implement command button types //if (type == GridButtonType.Image || type == GridButtonType.BareImage || type == GridButtonType.ImageAndText) //{ button.Decorators.Add(new GridButtonImageDecorator(button)); //} //if (type != GridButtonType.Image && type != GridButtonType.BareImage) //{ button.Decorators.Add(new GridButtonTextDecorator(button)); //} }
public object CustomCommandToolBarButton( string name, string text, string actionName, string controllerName, object routeValues, bool ajax, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { return(CustomCommandToolBarButton(name, text, null, actionName, controllerName, null, routeValues, ajax, buttonType, htmlAttributes, imageHtmlAttributes)); }
private object CustomCommandToolBarButton( string name, string text, string url, string actionName, string controllerName, string routeName, object routeValues, bool ajax, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { return(CustomButton <GridToolBarCustomCommand <T> >(name, text, url, actionName, controllerName, routeName, routeValues, ajax, buttonType, htmlAttributes, imageHtmlAttributes)); }
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 }
private static string GetClasses(GridButtonType gridButtonType, ButtonIcon buttonIcon) { var ms = _htmlButonType[gridButtonType].Replace("{CLASS}", _htmlButtonAction[buttonIcon].CssClasses); return(ms); }
public object CustomCommandToolBarButton(string name, string text, string routeName, RouteValueDictionary routeValues, bool ajax, GridButtonType buttonType) { return(CustomCommandToolBarButton(name, text, routeName, routeValues, ajax, buttonType, null, null)); }
public GridButtonWindowActionParameters(string name, string windowName, string controller, string action, object routeValues, ButtonIcon buttonIcon = ButtonIcon.Edit, GridButtonType gridButtonType = GridButtonType.Image) : base(name, controller, action, routeValues, buttonIcon, gridButtonType) { WindowName = windowName; }
public object InsertButton(GridButtonType buttonType) { return(InsertButton(buttonType, null)); }
public GridButtonActionParameters(string name, string controller, string action, object routeValues, ButtonIcon buttonIcon = ButtonIcon.Edit, GridButtonType gridButtonType = GridButtonType.Image) : base(name, controller, action, routeValues, buttonIcon) { GridButtonType = gridButtonType; }
public GridButtonActionParameters(string name, string urlAction, ButtonIcon buttonIcon = ButtonIcon.Edit, GridButtonType gridButtonType = GridButtonType.Image) : base(name, urlAction, buttonIcon) { GridButtonType = gridButtonType; }
public object InsertButton(GridButtonType buttonType, object htmlAttributes) { return(InsertButton(buttonType, htmlAttributes, null)); }
public object DeleteButton(T dataItem, GridButtonType buttonType, object htmlAttributes) { return(DeleteButton(dataItem, buttonType, htmlAttributes, null)); }
public ActionResult EditingServerSide(GridEditMode? mode, GridButtonType? type) { ViewData["mode"] = mode ?? GridEditMode.InLine; ViewData["type"] = type ?? GridButtonType.Text; return View(SessionProductRepository.All()); }
public object CustomCommandToolBarButton(string name, string text, string url, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { return(CustomCommandToolBarButton(name, text, url, null, null, null, null, false, buttonType, htmlAttributes, imageHtmlAttributes)); }
public object CustomCommandToolBarButton(string name, string text, string url, GridButtonType buttonType) { return(CustomCommandToolBarButton(name, text, url, buttonType, null, null)); }
public object SubmitChangesButton(GridButtonType buttonType) { return(SubmitChangesButton(buttonType, null)); }
public object EditButton(T dataItem, GridButtonType buttonType) { return(EditButton(dataItem, buttonType, null)); }
public object CustomCommandToolBarButton(string name, string text, string routeName, RouteValueDictionary routeValues, bool ajax, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes) { return(CustomCommandToolBarButton(name, text, null, null, null, routeName, routeValues, ajax, buttonType, htmlAttributes, imageHtmlAttributes)); }
public object DeleteButton(T dataItem, GridButtonType buttonType) { return(DeleteButton(dataItem, buttonType, null)); }
public ActionResult EditingWebService(GridEditMode? mode, GridButtonType? type) { ViewData["mode"] = mode ?? GridEditMode.InLine; ViewData["type"] = type ?? GridButtonType.Text; return View(); }
public object SubmitChangesButton(GridButtonType buttonType, object htmlAttributes) { return(SubmitChangesButton(buttonType, htmlAttributes, null)); }