Example #1
0
 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());
        }
Example #3
0
        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()));
        }
Example #4
0
        public object EditButton(T dataItem, GridButtonType buttonType, object htmlAttributes, object imageHtmlAttributes)
        {
            Editing.Enabled = true;

            RegisterEditingScriptFiles();
            return(Button <GridEditActionCommand>(dataItem, buttonType, htmlAttributes, imageHtmlAttributes));
        }
Example #5
0
        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));
        }
Example #6
0
        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);
        }
Example #10
0
        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
        }
Example #11
0
        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));
            }
        }
Example #14
0
        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));
            //}
        }
Example #15
0
 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));
 }
Example #16
0
 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));
 }
Example #17
0
        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);
        }
Example #19
0
 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;
 }
Example #21
0
 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;
 }
Example #24
0
 public object InsertButton(GridButtonType buttonType, object htmlAttributes)
 {
     return(InsertButton(buttonType, htmlAttributes, null));
 }
Example #25
0
 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());
 }
Example #27
0
 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));
 }
Example #28
0
 public object CustomCommandToolBarButton(string name, string text, string url, GridButtonType buttonType)
 {
     return(CustomCommandToolBarButton(name, text, url, buttonType, null, null));
 }
Example #29
0
 public object SubmitChangesButton(GridButtonType buttonType)
 {
     return(SubmitChangesButton(buttonType, null));
 }
Example #30
0
 public object EditButton(T dataItem, GridButtonType buttonType)
 {
     return(EditButton(dataItem, buttonType, null));
 }
Example #31
0
 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));
 }
Example #32
0
 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();
 }
Example #34
0
 public object SubmitChangesButton(GridButtonType buttonType, object htmlAttributes)
 {
     return(SubmitChangesButton(buttonType, htmlAttributes, null));
 }