Lets say my Razor view contains a ajax bound combo-box which is making ajax request to get the data.
Razor View:
@(Html.Kendo().ComboBoxFor(model => model.PrimaryInsurance) .Filter(FilterType.Contains) .Placeholder(Constants.K_ComboPlaceholder) .DataTextField(Constants.K_ComboDataTextField) .DataValueField(Constants.K_ComboDataValueField) .DataSource(src => src.Read(read => read.Action("GetPrimaryInsuranceList", "Patient", new { area = "Patient" }) .Data("AdditionalDataPatientId")) ) .HtmlAttributes(new { @class = "responsive-width" }) )
We need to send patientId as parameter to GetPrimaryInsuranceList action method, which is written in “Patient” Controller in “Patient” Area.
So what we need to do is, We just need to attach the event handler with Data attribute of the DataSource. And In our JS file, define the event attached with the Data attribute of the combo-box.
JS function:
function AdditionalDataPatientId() { return { patientId: SessionInfo.patientId }; }
And here is how our GetPrimaryInsuranceList action method will look like:
Action Method:
public ActionResult GetPrimaryInsuranceList(long patientId) { var result = patientService.GetPrimaryInsuranceList(patientId); return Json(result, JsonRequestBehavior.AllowGet); }
Thats all and we are done.