MultiSelect always returns null as Editor Template

3 posts, 0 answers
  1. Mike
    Mike avatar
    10 posts
    Member since:
    Sep 2014

    Posted 13 Dec 2018 Link to this post

    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>
          .DataSource(d => d
              .Read(r => r
                  .Action("OrderTypes_Read", "Locations")


    Here is the underlying model class:

    public class LocationsModel : INotifyPropertyChanged
        public LocationsModel() : base()
        public decimal LocationId { get; set; }
        public string ClientID { get; set; }
        public string LocationCode { get; set; }
        public string Name { get; set; }
        [DisplayName("Address 1")]
        public string Address1 { get; set; }
        private string address2;
        [DisplayName("Address 2")]
        public string Address2
            get => address2 ?? "";
            set => address2 = value ?? "";
        public string City { get; set; }
        public string State { get; set; }
        public string Country { get; set; }
        [DisplayName("Zip Code")]
        public string ZipCode { get; set; }
        public string PhoneNumber { get; set; }
        [DisplayName("Allowed Order Types")]
        public IEnumerable<int> OrderTypeIDs { get; set; }
        [DisplayName("# of O Types")]
        public int OrderTypeCount => OrderTypeIDs?.Count() ?? 0;
        public string CreatedBy { get; set; }
        public DateTime CreatedOn { get; set; }
        public string LastUpdatedBy { get; set; }
        public DateTime LastUpdatedOn { get; set; }
        public event PropertyChangedEventHandler PropertyChanged;
  2. Mike
    Mike avatar
    10 posts
    Member since:
    Sep 2014

    Posted 17 Dec 2018 in reply to Mike Link to this post

    Submitted Support Ticket
  3. Ivan Danchev
    Ivan Danchev avatar
    1887 posts

    Posted 18 Dec 2018 Link to this post

    Hello Mike,

    Consider using the MultiSelectFor helper in order to wire the MultiSelect to the model field:
    @(Html.Kendo().MultiSelectFor(m => m.OrderTypeIDs)
    //...additional configuration

    You can find a sample runnable MVC project, which demonstrates this approach attached to Atanas' post in the following forum thread.

    Ivan Danchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top