Exemplo n.º 1
0
        private object SaveButton(T dataItem, object htmlAttributes /*, object imageHtmlAttributes*/, string saveText, string cancelText)
        {
            var command = new GridToolBarSaveCommand <T>();

            command.ButtonType = GridButtonType.ImageAndText;

            if (saveText.HasValue())
            {
                command.SaveText = saveText;
            }

            if (cancelText.HasValue())
            {
                command.CancelText = cancelText;
            }

            command.HtmlAttributes = htmlAttributes.ToDictionary();

            var buttons = command.CreateDisplayButtons(UrlBuilder, new GridHtmlHelper <T>(ViewContext, DataKeyStore));

            var fragment = new HtmlFragment();

            buttons.Each(button => button.Create(dataItem).AppendTo(fragment));

            return(MvcHtmlString.Create(fragment.ToString()));
        }
Exemplo n.º 2
0
        //TODO: Implement command button types
        private object Button <TButton>(T dataItem /*, GridButtonType buttonType*/, object htmlAttributes, object imageHtmlAttributes, string text)
            where TButton : GridActionCommandBase, new()
        {
            var command = new TButton();

            //command.ButtonType = buttonType;
            command.ButtonType = GridButtonType.ImageAndText;

            if (text.HasValue())
            {
                command.Text = text;
            }

            command.HtmlAttributes = htmlAttributes.ToDictionary();

            //TODO: Implement command button image html attributes
            //command.ImageHtmlAttributes = imageHtmlAttributes.ToDictionary();

            var buttons = command.CreateDisplayButtons(UrlBuilder, new GridHtmlHelper <T>(ViewContext, DataKeyStore));

            var fragment = new HtmlFragment();

            buttons.Each(button => button.Create(dataItem).AppendTo(fragment));

            return(MvcHtmlString.Create(fragment.ToString()));
        }
Exemplo n.º 3
0
        private object CustomButton <TButton>(
            string name,
            string text,

            string url,
            string actionName,
            string controllerName,
            string routeName,
            object routeValues,
            //TODO: Implement command button types
            //  GridButtonType buttonType,
            object htmlAttributes,
            object imageHtmlAttributes)

            where TButton : GridCustomCommandBase, new()
        {
            var command = new TButton();

            //TODO: Implement command button types
            //command.ButtonType = buttonType;
            command.ButtonType     = GridButtonType.ImageAndText;
            command.HtmlAttributes = htmlAttributes.ToDictionary();

            //TODO: Implement command button html attributes
            //command.ImageHtmlAttributes = imageHtmlAttributes.ToDictionary();
            command.Text = text;
            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(UrlBuilder, new GridHtmlHelper <T>(ViewContext, DataKeyStore));
            var fragment = new HtmlFragment();

            buttons.Each(button => button.Create(null).AppendTo(fragment));

            return(MvcHtmlString.Create(fragment.ToString()));
        }