Esempio n. 1
0
        protected MvcHtmlString BaseButton(string displayName,
                                           ManipulationButtonStyle buttonStyle, IDictionary <string, object> htmlAttributes)
        {
            switch (buttonStyle)
            {
            case ManipulationButtonStyle.Button:
                return(MvcHtmlString.Create
                       (
                           string.Format("<input type=\"button\" value=\"{0}\" {1} />",
                                         CurrHtmlHelper.Encode(displayName),
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));

            case ManipulationButtonStyle.Image:
                htmlAttributes["src"] = displayName;
                BasicHtmlHelper.SetDefaultStyle(htmlAttributes, "cursor", "pointer");
                return(MvcHtmlString.Create
                       (
                           string.Format("<img {1} />",
                                         displayName,
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));

            default:
                htmlAttributes["href"] = "javascript:void(0);";
                return(MvcHtmlString.Create
                       (
                           string.Format("<a {1}>{0}</a>",
                                         CurrHtmlHelper.Encode(displayName),
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));
            }
        }
Esempio n. 2
0
        public MvcHtmlString SelectedItems(IDictionary <string, object> htmlAttributes = null)
        {
            List <ExtendedSelectListItem> selected = new List <ExtendedSelectListItem>();

            foreach (TValue val in Value)
            {
                if (allItemsDictionary.ContainsKey(val.ToString()))
                {
                    selected.Add(allItemsDictionary[val.ToString()]);
                }
            }
            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }
            htmlAttributes["data-elementispart"] = "true";
            return(MvcHtmlString.Create
                   (
                       RenderPackedList() +
                       CurrHtmlHelper.DropDownbase <TModel, TChoiceItem, TDisplay, TValue> (
                           BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectSelected,
                           new List <TValue>() as IEnumerable <TValue>,
                           selected,
                           htmlAttributes,
                           true,
                           false).ToString()
                   ));
        }
Esempio n. 3
0
        public MvcHtmlString AvailableItems(IDictionary <string, object> htmlAttributes = null)
        {
            List <ExtendedSelectListItem> NotSelected = new List <ExtendedSelectListItem>();

            foreach (ExtendedSelectListItem sel in allItems)
            {
                if (!valuesSet.Contains(sel.Value))
                {
                    NotSelected.Add(sel);
                }
            }
            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }
            htmlAttributes["data-elementispart"] = "true";
            return(MvcHtmlString.Create
                   (

                       CurrHtmlHelper.DropDownbase <TModel, TChoiceItem, TDisplay, TValue>(
                           BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectAvial,
                           new List <TValue>() as IEnumerable <TValue>,
                           NotSelected,
                           htmlAttributes,
                           true,
                           false).ToString()
                   ));
        }
Esempio n. 4
0
        protected string RenderPackedList()
        {
            PackedList <IEnumerable <TValue>, TValue> displayModel = new PackedList <IEnumerable <TValue>, TValue>();

            displayModel.ImportFromModel(Value, new object[] { DualSelect_Separator });

            StringBuilder sb = new StringBuilder();

            sb.Append(BasicHtmlHelper.RenderDisplayInfo(CurrHtmlHelper,
                                                        typeof(PackedList <IEnumerable <TValue>, TValue>),
                                                        Prefix));
            sb.AppendFormat("<span {2} style='display:none' id='{1}' is-item-control='true' pname='{0}' data-element-type = 'DualSelect' ></span>", _fullprefix, BasicHtmlHelper.IdFromName(_fullprefix), BasicHtmlHelper.GetAttributesString(AttributeExtensions));
            sb.Append(
                CurrHtmlHelper.Hidden(BasicHtmlHelper.AddField(Prefix, "$.Separator"),
                                      DualSelect_Separator, new RouteValueDictionary {
                { "data-elementispart", "true" }
            })).ToString();

            sb.Append(CurrHtmlHelper.Hidden(
                          BasicHtmlHelper.AddField(Prefix, "$.PackedValue"),
                          displayModel.PackedValue, new RouteValueDictionary {
                { "data-elementispart", "true" }
            }));
            return(sb.ToString());
        }
Esempio n. 5
0
 public MvcHtmlString SelectedItemsFilter(IDictionary <string, object> htmlAttributes = null)
 {
     return(MvcHtmlString.Create(
                CurrHtmlHelper.TextBox(
                    BasicHtmlHelper.AddField(Prefix, "$.PackedValue") + DualSelect_SelectedFilter,
                    null,
                    htmlAttributes).ToString() +
                string.Format(script, controlId, "true")
                ));
 }