/// <summary>
        ///
        /// </summary>
        public SelectedListItem.Builder SelectedListItem(SelectedListItem component)
        {
#if MVC
            component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null;
#endif
            return(new SelectedListItem.Builder(component));
        }
Exemplo n.º 2
0
        protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            this.HasLoadPostData = true;

            string text    = postCollection[this.UniqueName.ConcatWith("_text")];
            string values  = postCollection[this.UniqueName];
            string indexes = postCollection[this.UniqueName.ConcatWith("_indexes")];

            this.SuspendScripting();
            this.RawValue = text;
            this.ResumeScripting();

            if (values == null)
            {
                return(false);
            }

            bool fireEvent = false;

            if (values.IsEmpty())
            {
                fireEvent = this.SelectedItems.Count > 0;
                this.SelectedItems.Clear();
                return(fireEvent);
            }

            string[] arrValues  = values.Split(new[] { this.Delimiter }, StringSplitOptions.RemoveEmptyEntries);
            string[] arrIndexes = indexes.Split(new[] { this.Delimiter }, StringSplitOptions.RemoveEmptyEntries);
            string[] arrText    = new string[0];

            if (text.IsNotEmpty())
            {
                arrText = text.Split(new[] { this.Delimiter }, StringSplitOptions.RemoveEmptyEntries);
            }

            SelectedListItemCollection temp = new SelectedListItemCollection();

            for (int i = 0; i < arrValues.Length; i++)
            {
                string value = arrValues[i];
                string index = arrIndexes[i];
                string _text = arrText.Length > 0 ? arrText[i] : "";

                SelectedListItem item = new SelectedListItem(_text, value, int.Parse(index));

                temp.Add(item);

                if (!this.SelectedItems.Contains(item))
                {
                    fireEvent = true;
                }
            }

            this.SelectedItems.Clear();
            this.SelectedItems.AddRange(temp);

            return(fireEvent);
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            SelectedListItem tmp = (SelectedListItem)obj;

            return(this.Value == tmp.Value || this.Index == tmp.Index);
        }
 /// <summary>
 ///
 /// </summary>
 public SelectedListItem.Builder SelectedListItem(SelectedListItem component)
 {
     return(new SelectedListItem.Builder(component));
 }