【问题标题】:The call is ambiguous between the following methods - Kendo UI以下方法之间的调用不明确 - Kendo UI
【发布时间】:2014-09-15 22:07:37
【问题描述】:

我最近将一个 Web 应用程序从 Telerik Mvc 迁移到了 Kendo UI, 但我遇到了一个我不太确定如何修改的障碍,因为 在过去的一周里,我一直在学习并习惯 Kendo UI。

这是我遇到的问题。错误状态:

 The call is ambiguous between the following methods or 
 properties: 'System.Linq.Enumerable.Where<Model_OpenAccess_AssetMgr.Custody>
 (System.Collections.Generic.IEnumerable<Model_OpenAccess_AssetMgr.Custody>, 
 System.Func<Model_OpenAccess_AssetMgr.Custody,bool>)' 
 and 'System.Linq.Enumerable.Where<Model_OpenAccess_AssetMgr.Custody>
 (System.Collections.Generic.IEnumerable<Model_OpenAccess_AssetMgr.Custody>, 
 System.Func<Model_OpenAccess_AssetMgr.Custody,bool>)'

发生错误的代码如下:

@model List<Model_OpenAccess_AssetMgr.Custody>

<div id="AssetDescription" class="detailContainer detailContainer3">
<header class="sectionheader" >  Custodians </header>
@(Html.Kendo().Grid(Model.Where(x=>x.Active==true))
        .Name("grd_Admin_Custodians")
        .HtmlAttributes(new { @class = "ItemsGrid" })
        .ToolBar(commands => commands.Create())
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(o => o.Custody_PK))
        )
        .DataSource(dataSource => dataSource
             .Server()
             .Read(read => read.Action("AdminHome", "Admin", new { view ="Custodies" }))
             .Create("Create", "Admin", new { id = 0, view = "Custodies" })
             .Update("Save", "Admin", new { view = "Custodies" })
             .Destroy("Delete", "Admin", new { view = "Custodies" }))
        .Columns(columns =>
                {
                    columns.Bound(o => o.Custody_Name).Width(200);
                    columns.Bound(o => o.Custody_Dept).Width(150);
                    columns.Bound(o => o.Custody_eraider).Width(130);
                    columns.Bound(o => o.Custody_Type).Width(130);
                    columns.Bound(o => o.Custody_Email).Width(220);
                    {
                        commands.Edit();
                        commands.Destroy();
                    }).Width(210);
                }
       )
       .Scrollable(scrolling => scrolling.Enabled(true)}
       .Scrollable(scrolling => scrolling.Height(550))
       .Pageable()
       .Sortable()
    )
</div>
)

(Model.Where(x=>x.Active==true) 是被标记的内容。

现在,我还在下方顶部列出了一个警告

@model 列表说明:

ASP.NET runtime error: Method not found 'Void  
System.Web.Razor.RazorEngineHost.set_EnableInstrumentation(Boolean)'

我很确定这与我遇到的错误有关。

我是否需要以某种方式修改 Model.Where() 语句?

你认为我应该用什么来代替 Kendo UI?

另一方面,我最近将此 Web 应用程序项目从 MVC3 升级到 MVC4 所以我不知道这是否与此有关。但我想继续 并让您知道这一事实。

我查看了其他回复,但似乎没有人专门针对 Kendo UI 询问过这个问题。

谢谢!

【问题讨论】:

    标签: asp.net-mvc kendo-ui telerik system.web


    【解决方案1】:

    在我看来,您正在混合服务器端渲染和 Ajax 渲染。如果使用网格的服务器端渲染,您应该在模型(最好)或使用此视图的控制器操作(不太理想)中执行 Where(x=>x.Active==true) 过滤。不在视图中。

    如果使用 Ajax 获取数据,比如分页网格,您的数据源需要类似的读取方法

     .Read(read => read.Action("Custodians", "Admin"))
    

    【讨论】:

    • 是的,我在代码的“...”部分下方列出了 .Read(read => read.Action("Custodians", "Admin"))。我很可能会混合服务器端渲染和 Ajax 渲染。但如果这是真的,你建议我删除或修改什么来解决问题。我已经更新了包含完整代码的原始帖子,因此您可以更好地了解我正在使用的内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 2013-12-23
    • 1970-01-01
    • 2020-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多