I'm having difficulties with a telerik combobox that displays a blank value instead of the model's current value.
I have the below model :
public decimal? ResourceId { get; set; }
public string ResourceName{ get; set; }
public decimal ResourceTypeId { get; set; }
public string ResourceTypeName{ get; set; }
I wanted my view to display the ResourceTypeName in a combobox in order to be able to change it so I added the below to my model
public IEnumerable<ResourceTypeModel> ResourceType()
{
ResourceTypeModel a = new ResourceTypeModel();
a.ResourceTypeId = this.ResourceTypeId ;
a.ResourceTypeName= this.ResourceTypeName;
List<ResourceTypeModel> MyList= new List<ResourceTypeModel>();
MyList.Add(a);
return MyList;
}
Now, my view contains the following combobox :
@(Html.Telerik().ComboBoxFor(model => model.ResourceTypeId)
.AutoFill(true)
.DataBinding(binding => binding.Ajax().Select("_AutoCompleteAjaxLoadingResourceTypeList","ResourceController"))
.BindTo(new SelectList(Model.ResourceType(), "ResourceTypeId", "ResourceTypeName"))
.Filterable(filtering =>
{
filtering.FilterMode(AutoCompleteFilterMode.Contains);
filtering.MinimumChars(2);
})
.HighlightFirstMatch(true)
)
But when my view opens, the combobox shows a null value.
If I click the dropdown button of the combobox, the value I want to display appears as if it was a second item of the list and I can select it.
The combobox works perfectly for the autocompletion part and correctly shows all my available values when typing in it but simply does not show up directly with the needed value.