如何控制复选框并在网格剑道ui上显示

时间:2016-01-18 11:48:35

标签: javascript jquery kendo-ui kendo-grid

我是剑道ui的新手。我需要你的帮助。我需要在某个地方使用复选框。我的问题是当我编辑任何记录时,弹出菜单上的复选框可以显示属性的状态,但网格不显示。我想在网格上的复选框中显示记录显示的属性。

我尝试这个示例:http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Templates/grid-with-checkbox-column但它不适用于我的预期。

这是我的代码:

                    {
                        field: "isWorking",
                        title: "Çalışıyor",
                        editor: '<input type="checkbox" #= isWorking ? \'checked="checked"\' : "" # class="chkbx" />'
                    },
                    {
                        command: [
                            {
                                name: "edit",
                                text: {
                                    edit: "",
                                    update: "Tamam",
                                    cancel: "İptal"
                                },
                                className: "grid-command-iconfix"
                            },
                            {
                                name: "destroy",
                                text: "",
                                className: "grid-command-iconfix"
                            }
                        ],
                        title: "&nbsp;",
                        width: "120px"
                    }
                ],
                editable: {
                    mode: "popup",
                    window: {
                        title: "Kayıt".i18n()
                    },
                    confirmation: "Silmek istediğinizden emin misiniz?".i18n(),
                    confirmDelete: "Yes"
                },
                edit: function (e) {
                    console.log(e);
                    $("#maritalStatus").data("kendoDropDownList");
                }
            });
        }
    });

    $("personGrid.k-grid-content").on("change","input.chkbx",function(e){
        var grid = $("#personGrid").data("kendoGrid"),
            dataItem = grid.dataItem($(e.target).closest("tr"));

        dataItem.set("isWorking", this.checked);
    });

它的工作原理截图。请关注ss。 enter image description here

enter image description here

从这里开始,这是linke的解决方案,由我提出问题。

这里的代码是我的第一份工作:

 {
                        field: "isWorking",
                        title: "Çalışıyor",
                        template: "<input type='checkbox' id='isWorking'/>"
                    },
                    {
                        command: [
                            {
                                name: "edit",
                                text: {
                                    edit: "",
                                    update: "Tamam",
                                    cancel: "İptal"
                                },
                                className: "grid-command-iconfix"
                            },
                            {
                                name: "destroy",
                                text: "",
                                className: "grid-command-iconfix"
                            }
                        ],
                        title: "&nbsp;",
                        width: "120px"
                    }
                ],
                editable: {
                    mode: "popup",
                    window: {
                        title: "Kayıt".i18n()
                    },
                    confirmation: "Silmek istediğinizden emin misiniz?".i18n(),
                    confirmDelete: "Yes"
                },
                edit: function (e) {
                    console.log(e);
                    $("#maritalStatus").data("kendoDropDownList");
                }
            });
        }
    });

这里是如何工作的。它在弹出编辑菜单上显示状态,但不显示在网格上。 enter image description here

你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

您在模板中设置了复选框,但没有设置其值。它将始终处于初始状态。试试这个模板:

template: "<input type='checkbox' id='isWorking' # if (isWorking) { # checked=\"checked\" # } # />"

Demo