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

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

我想向 Kendo 调度程序添加共享功能,为了做到这一点,我希望共享字段是一个复杂的对象,而不仅仅是一个简单的字符串。

所以我想做的是:

    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 },
                    }],
            }
        }

有人能帮帮我吗?

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

根据 api 文档 kendo

parse

Executed before the server response is used. Use it to preprocess or parse the server response.

我在 coffeescript 中这样使用它:

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