How to show data of child view model by targeting parent view model in Kendo Multiselect dropdown in MVC?

15 Views Asked by At

Parent view model declaration:

 public class PublishReportDataViewModal
 {
     public string ReportPeriodName { get; set; }
     public string YearName { get; set; }
     public long SchoolId { get; set; }
     public bool CanPublish { get; set; }
     public bool CanEmail { get; set; }
     [Required(ErrorMessage = "Please select Roll Group")]
     public List<RollGroupDetailsViewModel> RollGroupDetails { get; set; }
 }

Child View model declaration:

 public class RollGroupDetailsViewModel
 {
     public string RollGroup { get; set; }
     public long RollGroupId { get; set; }
     public string Name { get; set; }
 }

Main modal is declared in my partial view page which is PublishReportDataViewModel. I'm filling several data in RollGroupViewModel which is in list and I want to show that data via Kendo multiselect drop down.

I've written below code of cshtml but it's now working.

 @(Html.Kendo().MultiSelect()
     .Name("rollGroupDetailsMultiSelect")
     .Placeholder("Select Roll Groups")
     .DataTextField("Name")
     .DataValueField("Name")
     .BindTo(Model.RollGroupDetails.Select(rg => rg.Name))
 )

Kindly suggest me solution.

Regards, Jay Chaniyara

0

There are 0 best solutions below