Kendo UI 未定义网格复选框列字段

Kendo UI Grid Checkbox Column Field Not Defined

我正在尝试添加一个 kendo 复选框列。我已经在另一个网格中成功地做到了这一点。然而,当我试图在另一个网格中做同样的事情时,我收到了 "IsSimple is undefined" 错误,其中 IsSimple 是一个简单的布尔模型字段。

我的 kendo 数据源的模型:

     schema: {
                data: function (data) { //specify the array that contains the data
                    console.log("DATA RETURN TEST");
                    console.log(data);
                    return data || [];
                },
                model: {
                    id: "Id",
                    fields: {
                        Id: { editable: false,
                            nullable: false,
                            type: "number"
                        },
                        DesignatorName: { type: "string" },
                        TXFreq: { type: "string" },
                        RXFreq: { type: "string" },
                        IsSpecial: { type: "bool" },
                        IsCommand: { type: "bool" },

                    }
                }

这是我的 kendo 网格的列定义。

        $("#DesignatorFreqGrid").kendoGrid({
            dataSource: DesignatorDS,

            columns: [

                   { field: "DesignatorName", title: "Frequency", format: "{0:c}", width: "120px" },
                   { field: "TXFreq", editor: TXFreqEditor, title: "TX Frequency", format: "{0:c}", width: "120px" },
                   { field: "RXFreq", editor: TXFreqEditor, title: "RX Frequency", format: "{0:c}", width: "120px" },
                   { field: "IsSpecial", template: '<input type="checkbox" #= IsSpecial ? checked="checked" : "" # disabled="disabled" ></input>', title: "Is Special", format: "{0:c}", width: "120px" },
                   { field: "IsCommand", template: '<input type="checkbox" #= IsCommand ? checked="checked" : "" # disabled="disabled" ></input>', title: "Is Command", format: "{0:c}", width: "120px" },


                { command: ["edit", "destroy"], title: "&nbsp;", width: "250px" }
            ],
            toolbar: ["create"],
            editable: "inline",
            pageable: true

        });

这是我的 JSON 对象:

"other fields........DesignatorName: "11"
EQUIPMENT: ObjectId: 2
IsCommand: true
IsSpecial: true
RXFreq: "55"
TXFreq: "22"

如您所见,IsSpecial 已定义。 当我将数据加载到网格中时,绑定有效。确实选中了复选框。 但是如果我尝试在网格中使用 "Add New Record" 按钮添加新记录,我将收到错误消息 "Uncaught ReferenceError: IsSpecial is not defined"。

如果我将绑定更改为 this.IsSpecial,我不会再收到错误,并且可以向我的数据库中添加一个新行,但是绑定将不起作用,框也不会加载网格时检查,

看起来应该可行,但我不知道还能去哪里查看。有任何想法吗?谢谢。

您需要使用 boolean,而不是 bool

IsSpecial: { type: "boolean" },
IsCommand: { type: "boolean" }