Kendo网格-详细信息模板-数据源读取未触发控制器操作 [英] Kendo Grid - Detail Template - DataSource Read is not firing the controller action

查看:130
本文介绍了Kendo网格-详细信息模板-数据源读取未触发控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用类型:带有Kendo框架的ASP.NET MVC

App type: ASP.NET MVC with Kendo framework

遇到问题:详细信息模板未触发控制器操作方法.也请找到随附的屏幕截图.我也在firebug窗口下进行了检查,没有对控制器操作方法"PublishedImportFiles_Read" 的ajax调用.这让我疯狂又烦人.对于该异常,不会引发或显示任何错误.我想我缺少的东西很小.

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.

请帮助.

MVC-查看代码

 <div class="gapLeft gapBelow20" style="width:70%;">
    @(Html.Kendo().Grid<ViewModels.PublishedImportViewModel>()
                    .Name("GridImport")
                    .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");

                    })
                       .Scrollable()
                       .ClientDetailTemplateId("tplGridImport")
                       .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); })
                               )
                  )
</div>

<script id="tplGridImport" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<ViewModels.PublishedImportViewModel>()
         .Name("GridImport_#=TemplateGroupID#")
        .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"); })
                         )
        .ToClientTemplate()
    )
</script>

导入控制器ActionResult方法:

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);

    } 

推荐答案

KendoGrid代码没有错.奇怪的是,另一个js文件中有一个JavaScript错误.出于某些奇怪的原因,它破坏了详细信息模板网格的绑定.

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.

这篇关于Kendo网格-详细信息模板-数据源读取未触发控制器操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆