3
votes

I am trying to add a kendo checkbox column. I have done this successfully in another grid. However, when I tried to do the same thing in another grid, I am getting a "IsSimple is undefined" error, where IsSimple is a simple boolean model field.

Model for my kendo data source:

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

                    }
                }

Here is my column definition for my 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

        });

Here is my JSON object:

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

As you can see, IsSpecial is defined. The binding works when I load data into the grid. The checkboxes are indeed checked. But if I try to add a new record with the "Add New Record" button in the grid, I will get the error "Uncaught ReferenceError: IsSpecial is not defined".

If I change the binding to this.IsSpecial, I don't get the error anymore, and can add a new row to my database, but then the binding won't work and the boxes aren't checked when loading the grid,

It seems like it should work, and I do not know where else to look. Any ideas? Thanks.

1
Can you please post the full grid source code, including the model.Nicholas

1 Answers

3
votes

You need to use boolean, instead of bool.

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