I have a multiselect setup as an Editor Template utilized by the grids popup editor, the control loads properly, displays the data, allows me to select multiple Order Types, but then returns null to my model every time when I save the changes on the popup editor.
How do I wire up the value of the MultiSelect to my model when it is an Editor Template for a Grid Popup?
Here is my Editor Template code:
@model IEnumerable<
int
>
@(Html.Kendo().MultiSelect()
.Name("OrderTypeIDs")
.DataTextField("Description")
.DataValueField("OrderTypeID")
.DataSource(d => d
.Ajax()
.Read(r => r
.Action("OrderTypes_Read", "Locations")
.Data("GetSelectedClientID")))
.TagMode(MultiSelectTagMode.Multiple)
.Value(Model)
)
Here is the underlying model class:
public class LocationsModel : INotifyPropertyChanged
{
public LocationsModel() : base()
{
}
[ScaffoldColumn(false)]
public decimal LocationId { get; set; }
[ScaffoldColumn(false)]
public string ClientID { get; set; }
[DisplayName("Code")]
[Required]
public string LocationCode { get; set; }
[Required]
public string Name { get; set; }
[DisplayName("Address 1")]
[Required]
public string Address1 { get; set; }
private string address2;
[DisplayName("Address 2")]
public string Address2
{
get => address2 ?? "";
set => address2 = value ?? "";
}
[Required]
public string City { get; set; }
[Required]
public string State { get; set; }
[Required]
public string Country { get; set; }
[DisplayName("Zip Code")]
[Required]
public string ZipCode { get; set; }
[DisplayName("Phone")]
[Required]
public string PhoneNumber { get; set; }
[UIHint("OrderTypeIDs")]
[DisplayName("Allowed Order Types")]
public IEnumerable<
int
> OrderTypeIDs { get; set; }
[DisplayName("# of O Types")]
[ReadOnly(true)]
public int OrderTypeCount => OrderTypeIDs?.Count() ?? 0;
[ScaffoldColumn(false)]
public string CreatedBy { get; set; }
[ScaffoldColumn(false)]
public DateTime CreatedOn { get; set; }
[ScaffoldColumn(false)]
public string LastUpdatedBy { get; set; }
[ScaffoldColumn(false)]
public DateTime LastUpdatedOn { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}