如何将复杂对象绑定到剑道调度程序中的字段

How can I bind complex object to a field in Kendo Scheduler

本文关键字:调度程序 字段 复杂 对象 绑定      更新时间:2023-09-26

我想为Kendo Scheduler添加共享功能,为了做到这一点,我希望共享字段是一个复杂的对象,而不仅仅是一个简单的strin。

所以我想做的是:

    schema: {
        model: {
            id: "taskId",
            fields: {
                taskId: { from: "Id", type: "number" },
                title: { from: "Title", defaultValue: "No title", validation: { required: true }                                },
                start: { type: "date", from: "StartsOn" },
                end: { type: "date", from: "EndsOn" },

                Share:[
                    {
                        user: { from: "users", defaultValue: 1 }, //users is a resource
                        right: { from: "rights", defaultValue: 1 },
                    }],
            }
        }

有人可以帮助我吗?

你可以做的是使用schema:{parse:}。

根据剑道的 API 文档

解析

在使用服务器响应之前执行。使用它进行预处理或 分析服务器响应。

我在咖啡脚本中使用它,如下所示:

schema:
  model:
    id: "id"
    fields:
      id: editable: false
      title: from: "name"
  parse: (response)->
    $(response).each ->
      this.share = [{user: this.users, right: this.rights}]
    return response