【问题标题】:ASP.NET Core OData web service, Angular 5 and Grid Component in Kendo UI for Angular用于 Angular 的 Kendo UI 中的 ASP.NET Core OData Web 服务、Angular 5 和网格组件
【发布时间】:2018-10-19 10:09:26
【问题描述】:

我想知道是否有一种简单的方法可以将 Kendo Angular Grid 绑定到 ASP.NET Core OData 控制器。我说的容易是什么意思?

好吧,在 jQuery 的 Kendo UI 中,我们需要做的就是在 DataSource 对象中指定“类型”和“传输”属性;参考:https://demos.telerik.com/kendo-ui/grid/odatav4

同样适用于 ASP.NET MVC 的 Kendo;参考:https://demos.telerik.com/aspnet-mvc/grid/odata

但是,我认为我已经阅读了整个文档,并且找不到以类似方式将 OData 服务与 Kendo Angular Grid 绑定的方法。

此页面包含有关网格数据绑定的一些信息:https://www.telerik.com/kendo-angular-ui/components/grid/data-binding/ ...但是,公开 ProductService 类的“northwind.service.ts”文件包含两个方法,看起来它们执行某种“硬编码”OData 过滤。

在“与 ASP.NET Core 的 UI 集成”页面 (https://www.telerik.com/kendo-angular-ui/components/dataquery/mvc-integration/) 中,有一个指向该项目的链接:https://github.com/telerik/kendo-angular-demo-aspnetcore-data/tree/master,但是作为后端的 ASP.NET Core Controller 不是基于 ODataController 和而是返回 JsonResult。也许有一种方法可以更改后端实现,但是我不确定使用提供的客户端代码是否一切都能正常工作。

我还发现了这个 GitHub 存储库:https://github.com/urfnet/URF.Core.Sample,它看起来很有前途,有一个专用的“服务”似乎可以处理所有 http 操作(GET、POST、PUT..)并且看起来非常“可重用”。

​ 我错过了什么还是没有简单的方法?我真的需要编写自己的服务来处理 Kendo Angular Grid 和 ASP.NET Core Odata 通信吗?

(我正在使用 ASP.NET Core 2、Angular 5、最新的 Kendo UI for Angular 和 OData 包,在本文中有所描述:https://blogs.msdn.microsoft.com/odatateam/2018/07/03/asp-net-core-odata-now-available/

【问题讨论】:

    标签: angular asp.net-core angular5 odata kendo-ui-angular2


    【解决方案1】:

    Angular Grid 的 Kendo UI 不知道其数据来自何处,并依赖于发出包含处理数据(或执行远程 HTTP 请求)所需信息的事件:

    DOCS

    examples that communicate with a sample OData backend 还利用 Data Query toODataString helper function 将传入的 Grid 状态转换为与 OData4 兼容的字符串。

    您可以创建一个数据服务来接收 Grid 状态并处理远程 HTTP 请求和响应(最终将由 Grid 使用),或者创建一个自定义自动绑定指令来抽象出所有与数据相关的操作,例如:

    EXAMPLE with step-by-step instructions

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 1970-01-01
      • 2017-12-29
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      相关资源
      最近更新 更多