如何将数据(JSON 格式)从本地数据库绑定到 Kendo UI 调度程序?

How can I bind data (in JSON format) from local database to Kendo UI Scheduler?

在对 Kendo UI 框架做了一些调整之后,我在使用他们的一个小部件时遇到了问题。我对框架只有基本的了解,这甚至是我在 Whosebug 中提出的第一个问题,所以...如果可能,请让我免于回答 "advanced"。

所以,事情是这样的:

我想使用 Scheduler 小部件使用 JSON 文件中的数据制作时间轴月视图。我计划使用的数据(JSON 格式)来自 SQL 服务器数据库,该数据库由连接到 Web 服务的 Ajax 调用在客户端调用。示例:

Params.type = 'GET';
Params.url = 'LoremIpsum-YeahDomainService.svc/JSON/GetPeople';
Params.dataType = 'json'

为了了解 Web 服务是否正常工作,我尝试从数据库中检索信息到 Kendo DropDownList 中,一切正常。我做了这个脚本:

var getPeople;
getPeople = data.GetPeopleResult.RootResults;
var listPeople = [];
getPeople.forEach(function(person){
   var newelement = { 'Name': person.Name, 'value': i, 'color': '#808080' };
   listPeople.push(newelement);
});

完成该脚本后,我使用了以下脚本:

$("#dropdownlist").kendoDropDownList({
  dataTextField: "Name",
  dataValueField: "value",
  dataSource: new kendo.data.DataSource ( { listPeople } )
});

按计划,我在浏览器中得到了我想看到的所有数据。

因此,现在我想为 Kendo Scheduler 制作脚本,其时间轴月份视图类似于 this 没有 "Meeting Rooms" 部分的脚本,我想要那些人的名字从数据库调用。

就像 DropDownList 一样,我有 30 或 300 个人名都没有关系。 Scheduler 上的人员不能是静态的,因为数据库会经常更新。简而言之,调度程序中显示的人员姓名必须从数据库中动态提供。

我已经使用了 Kendo UI 调度程序文档中的多个脚本,因为我所有的小部件脚本都基于他们的示例,但直到现在,还没有任何结果。

根据 Kendo UI 文档中提供的时间线月视图示例,我改编了他们的一些脚本,例如:

dataSource: {
   batch: true
   transport: {
      read: {
         url: "http://localhost:50379/LoremImpsum-YeahDomainService.svc/json/GetPeople",
         dataType: "json"

group: {
   resources: ["People"],
   orientation: "vertical"

关于调度程序脚本,基于 Telerik 网站上提供的示例,我编写了一个脚本,该脚本将从数据库中获取人员姓名。在这里:

var result = [];
result[0] = { text: "+getPeople[0]+", value: "1", color: "green" }";

for(i=1; i<getPeople.length(); i++){
   resultado[i] = ", { text: "+getPeople[i]+"value: "+(i+1)+", color: "green";
   i=i+1;
});

考虑到该脚本,我的想法是在 Scheduler 小部件的资源部分调用该数组,如下所示:

resources: [
   {
      field: "people",
      name: "People",
      dataSource: [ data: getPeople
        ]
]

有什么想法或想法吗?

P.S.

我还使用 Kendo UI Dojo 基于 Kendo 文档创建了一些脚本,您可以看到我需要的视图类型 there

对于未来可能感兴趣的人,我找到了一种方法。简而言之,非常快速和简单:

resources: [{
   field: "Name",
   name: "People",
   dataTextField: "Name",
   dataValueField: "Name",
   dataSource: new kendo.data.DataSource({
      transport: {
         read: {
            url: "http://localhost:50379/LoremImpsum-YeahDomainService.svc/json/GetPeople"
         }
      },
      schema: {
         type: "json",
         data: "GetPeopleResult.RootResults"
      }
   }
),
   multiple: true,
   title: "name"
}]