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

时间:2015-03-30 20:16:59

标签: javascript jquery kendo-ui kendo-grid

我正在尝试添加一个kendo复选框列。我在另一个网格中成功完成了这项工作。但是,当我试图在另一个网格中做同样的事情时,我得到一个“IsSimple is undefined”错误,其中IsSimple是一个简单的布尔模型字段。

我的剑道数据源模型:

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

                    }
                }

这是我的kendoGrid的列定义。

        $("#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已定义。 当我将数据加载到网格中时绑定有效。确实选中了复选框。 但是如果我尝试使用网格中的“添加新记录”按钮添加新记录,我将收到错误“Uncaught ReferenceError:IsSpecial未定义”。

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

它似乎应该有效,我不知道还有什么要看。有任何想法吗?感谢。

1 个答案:

答案 0 :(得分:2)

您需要使用boolean,而不是bool

IsSpecial: { type: "boolean" },
IsCommand: { type: "boolean" }
相关问题