In MVC method for controller is not called from inside of the Editor Template

28 Views Asked by At

I need to initialize Kendo.ComboBox inside of the Editor Template. I have defined the template as follows:

<script>
    function GetReportID() {
        return {
            reportID: 8
        }
    }
</script>

@(Html.Kendo().ComboBox()
                    .DataValueField("ReportPropertyID")
                    .DataTextField("PropertyName")
                    .DataSource(d => d.Read(r => r.Action("PopulateReportProperty", "TestTicketReportProperty").Data("GetReportID()")))) 

This template is rendered inside of the Kendo.Grid:

columns.Bound(p => p.ReportPropertyData).ClientTemplate("#=ReportProperty.PropertyName#").EditorTemplateName("_PropertyNameEditor").Sortable(false).Width(180);

The method inside of the controller that needs to be called:

[HttpPost]
public ActionResult PopulateReportProperty([DataSourceRequest] DataSourceRequest request, int reportID)
{
    var reportProperty = TicketReportPropertyRepository.GetReportPropertyEntityRepository(reportID);
    ViewData["defaultPropertyEntity"] = reportProperty.First();
    return Json(reportProperty.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

This method is not called.

What am I doing wrong?

1

There are 1 best solutions below

0
Kevin On

Is your _PropertyNameEditor file located inside your Views>Shared>EditorTemplates folder?

Also you may need to do [UIHint("_PropertyNameEditor")] on the attribute in your ViewModel.