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)); }
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); }
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); }
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); }
public HtmlTag Build(ElementRequest request) { return _creators[request.ToAccessorDef()](request); }
public HtmlTag Build(ElementRequest request) { return(_creators[request.ToAccessorDef()](request)); }
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); }
public HtmlTag Build(ElementRequest request, int index, int count) { return _creators[request.ToAccessorDef()](request, index, count); }