public override HtmlTag Build(ElementRequest request)
        {
            Action <SelectTag> action = x =>
            {
//                                               var value = request.RawValue is Entity ? ((Entity)request.RawValue).EntityId : request.RawValue;
                var value = request.RawValue;

                var propertyName     = request.ToAccessorDef().Accessor.FieldName;
                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName + "List");
                var selectListItems  = listPropertyInfo.GetValue(request.Model, null) as IEnumerable <SelectListItem>;
                if (selectListItems == null)
                {
                    return;
                }

                selectListItems.ForEachItem(option => x.Option(option.Text, option.Value.IsNotEmpty() ? option.Value: ""));

                if (value != null && value.ToString().IsNotEmpty())
                {
                    x.SelectByValue(value.ToString());
                }
                x.AddClass("fixedWidthDropdown");
            };

            return(new SelectTag(action));
        }
Example #2
0
        public override HtmlTag Build(ElementRequest request)
        {
            Action <SelectTag> action = x =>
            {
                var value = request.RawValue;

                var propertyName     = request.ToAccessorDef().Accessor.FieldName;
                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName + "List");
                var dictionary       = listPropertyInfo.GetValue(request.Model, null) as IDictionary <string, IEnumerable <SelectListItem> >;
                if (dictionary == null)
                {
                    return;
                }
                x.Option(CoreLocalizationKeys.SELECT_ITEM.ToString(), "");
                dictionary.Keys.Each(key =>
                {
                    x.OptGroup(key);
                    dictionary[key].Each(l => x.Option(l.Text, l.Value + "_" + key));
                });
                if (value != null && value.ToString().IsNotEmpty())
                {
                    x.SelectByValue(value.ToString());
                }
            };

            return(new SelectTag(action));
        }
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
                                           {
                                               var value = request.RawValue is DomainEntity ? ((DomainEntity)request.RawValue).EntityId : request.RawValue;

                                                var propertyName = request.ToAccessorDef().Accessor.FieldName;
                                                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName+"List");
                                               var selectListItems = listPropertyInfo.GetValue(request.Model, null) as IEnumerable<SelectListItem>;
                                               if (selectListItems == null) return;

                                               selectListItems.Each(option=> x.Option(option.Text, option.Value.IsNotEmpty() ? option.Value: ""));

                                               if (value != null && value.ToString().IsNotEmpty())
                                               {
                                                   x.SelectByValue(value.ToString());
                                               }
                                           };
            return new SelectTag(action);
        }
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
            {
                var value = request.RawValue;

                var propertyName = request.ToAccessorDef().Accessor.FieldName;
                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName + "List");
                var dictionary = listPropertyInfo.GetValue(request.Model, null) as IDictionary<string, IEnumerable<SelectListItem>>;
                if (dictionary == null) return;
                x.Option(CoreLocalizationKeys.SELECT_ITEM.ToString(),"");
                dictionary.Keys.Each(key =>
                {
                    x.OptionGroup(key);
                    dictionary[key].Each(l => x.Option(l.Text, l.Value+"_"+key));
                });
                if (value != null && value.ToString().IsNotEmpty())
                {
                    x.SelectByValue(value.ToString());
                }
            };
            return new SelectTag(action);
        }
Example #5
0
        private HtmlTag buildTag(ElementRequest request)
        {
            var accessorDef = request.ToAccessorDef();

            foreach (var builder in _sources)
            {
                var creator = builder.CreateInitial(accessorDef);
                if (creator == null) continue;

                var tag = creator(request);
                if (tag != null) return tag;
            }

            throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name);
        }
Example #6
0
        private HtmlTag buildTag(ElementRequest request)
        {
            var accessorDef = request.ToAccessorDef();

            foreach (var builder in _sources)
            {
                var creator = builder.CreateInitial(accessorDef);
                if (creator == null)
                {
                    continue;
                }

                var tag = creator(request);
                if (tag != null)
                {
                    return(tag);
                }
            }

            throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name);
        }
Example #7
0
 public HtmlTag Build(ElementRequest request)
 {
     return _creators[request.ToAccessorDef()](request);
 }
Example #8
0
 public HtmlTag Build(ElementRequest request)
 {
     return(_creators[request.ToAccessorDef()](request));
 }
Example #9
0
 public HtmlTag Build(ElementRequest request, int index, int count)
 {
     return(_creators[request.ToAccessorDef()](request, index, count));
 }
 public override HtmlTag Build(ElementRequest request)
 {
     var accessorDef = request.ToAccessorDef();
     var literalList = accessorDef.Accessor.PropertyType.GetGenericArguments().Single();
     return BuildTag(request, literalList);
 }
Example #11
0
 public HtmlTag Build(ElementRequest request, int index, int count)
 {
     return _creators[request.ToAccessorDef()](request, index, count);
 }