I am working on asp.net mvc with the kendo mvc interface. I have two kendo dropdowns. one for the list of clinics and another for the list of patients in the selected clinic. But there is no direct connection between the clinics and the patient in order to use the cascading drop-down list. To do this, I used ajax calls in the list change event and got a list of patients. and this is my first drop down list for list clinics
@( Html.Kendo().DropDownList() .Name("ddlClinics") .Events(e=>e.Change("ChangeClinic")) .BindTo(new SelectList((List<Account.Entities.Clinic>)ViewBag.lstClinic, "ClinicID", "ClinicName")))
and this is my second dropdown for listpatients
@( Html.Kendo().DropDownList() .Name("ddlPatients") .BindTo(new SelectList((List<Patient>)ViewBag.Patients, "PatId", "PatName"))))
I want to dynamically link the patient list to the second drop-down list when the first drop-down list changes
function ChangeClinic() { $.ajax({ url: '/Messages/GetPatient', type: 'Post', data: { email: '@User.Identity.Name' }, cache: false, success: function (result) { var ddlPatients = $('#ddlPatients').data('kendoDropDownList'); var main = []; $.each(result, function (k, v) { main.push({ "PatId": v.PatId, "PatName": v.PatName }); }); ddlPatients.dataTextField = "PatName"; ddlPatients.dataValueField = "PatId"; ddlPatients.dataSource.data(main); ddlPatients.reload(); } }); }
I can associate the list with a drop-down list, but all items are displayed as 'undefined' . so please guide me.
source share