【问题标题】:Kendo UI Grid Checkbox Column Field Not DefinedKendo UI 网格复选框列字段未定义
【发布时间】:2015-03-30 20:16:58
【问题描述】:

我正在尝试添加一个剑道复选框列。我已经在另一个网格中成功地做到了这一点。但是,当我尝试在另一个网格中执行相同的操作时,我收到“IsSimple 未定义”错误,其中 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 已定义。 当我将数据加载到网格中时绑定起作用。确实选中了复选框。 但如果我尝试使用网格中的“添加新记录”按钮添加新记录,我会收到错误“未捕获的 ReferenceError: IsSpecial is not defined”。

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

它似乎应该可以工作,但我不知道该去哪里找。有任何想法吗?谢谢。

【问题讨论】:

  • 能否请您发布完整的网格源代码,包括模型。

标签: javascript jquery kendo-ui kendo-grid


【解决方案1】:

您需要使用boolean,而不是bool

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

【讨论】:

  • 这恐怕是我对剑道的期待。他们应该让“布尔”工作,这是我们花费数小时修复的东西
猜你喜欢
  • 2016-12-31
  • 2023-03-23
  • 1970-01-01
  • 2015-05-21
  • 2013-04-08
  • 1970-01-01
  • 1970-01-01
  • 2018-06-23
  • 2018-12-03
相关资源
最近更新 更多