[Solved] Kendo Grid – Detail Template – DataSource Read is not firing the controller action

App type: ASP.NET MVC with Kendo framework

Problem Encountered: The detail template is not firing the controller action method. Please find the attached screenshot also. I checked it under the firebug window also, there is no ajax call to the controller action method “PublishedImportFiles_Read”. This is making me crazy and annoying. No error is thrown or shown for this anomaly. I guess i am missing something very small.

Please help.

enter image description here

MVC – View Code

 <div class="gapLeft gapBelow20" style="width:70%;">
                    .Columns(columns =>
                        columns.Bound(p => p.TemplateGroup).Title("Template Group").Width("120px");
                        columns.Bound(p => p.TaxYear).Title("Tax Year").Width("70px");
                        columns.Bound(p => p.FileDescription).Title("Description").Width("200px");
                        columns.Bound(p => p.DatePublished).Title("Published Date").Format("{0:MM/dd/yyyy}").Width("100px");
                        columns.Bound(p => p.PublishedBy).Title("Published By").Width("100px");

                       .Events(et => et.DataBound(fnCall.Replace("functionName", "gridImpDataBound")))
                       .Events(et => et.DetailInit(fnCall.Replace("functionName", "gridImpChildInit")))
                       .HtmlAttributes(new { style = "height:300px;" })                           
                       .DataSource(ds => ds.Ajax().ServerOperation(false)
                               .Read(read => { read.Action("PublishedImport_Read", "Import"); })
                               .Model(m => { m.Id(p => p.TemplateGroupID); })

<script id="tplGridImport" type="text/kendo-tmpl">
        .Columns(columns =>
            columns.Bound(c => c.TemplateGroup).Title("Template Group").Width("120px");
            columns.Bound(c => c.TaxYear).Title("Tax Year").Width("70px");
        .DataSource(dsx => dsx.Ajax()
                            .Read(rd => { rd.Action("PublishedImportFiles_Read", "Import"); })

Import Controller ActionResult Method:

 [OutputCache(Duration = 0)]
    public ActionResult PublishedImportFiles_Read([DataSourceRequest] DataSourceRequest request)
        int groupID = 5;
        IEnumerable<PublishedImportViewModel> pubVM = Enumerable.Empty<PublishedImportViewModel>();
        var pubRecords = base.ScenarioMangtService.GetPublishedImportFilesByTemplateGroup(ClientID, SelectedYear, groupID);

        pubVM = pubRecords.Select(s => new PublishedImportViewModel
                                                        ImportFileJobID = s.ImportFileJobID,
                                                        TemplateGroupID = s.TemplateGroupID,
                                                        TemplateGroup = s.TemplateGroup,
                                                        FileName = s.FileName,
                                                        FileDescription = s.FileDescription,
                                                        TaxYear = SelectedYear,
                                                        DatePublished = s.DatePublished,
                                                        PublishedBy = s.PublishedBy

        return Json(pubVM.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);

Enquirer: Karan


Solution #1:

There was nothing wrong with the KendoGrid code. Strangely, there was a javascript error in another js file. And for some weird reason, it was breaking the binding of the detail template grid.

So when i commented the other broken code in another file, this grid starts working automatically.

Respondent: Karan

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.