简体   繁体   English

如何控制复选框并在网格Kendo UI上显示

[英]how to control check box and show on grid kendo ui

I am new on kendo ui. 我是Kendo ui的新手。 I need your help, please. 我需要你的帮助。 I need to use checkbox somewhere. 我需要在某处使用复选框。 My problem is when I edit any record, checkbox which is on popup menu can show status of attribute but grid doesn't show. 我的问题是,当我编辑任何记录时,弹出菜单上的复选框可以显示属性状态,但是不显示网格。 I want to show attribute of the record show in checkbox on grid. 我想在网格的复选框中显示记录显示的属性。

I try to this sample : http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Templates/grid-with-checkbox-column but It doesn't work for my expected. 我尝试使用以下示例: http : //docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Templates/grid-with-checkbox-column但它不适用于我的预期。

Here is my code: 这是我的代码:

                    {
                        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);
    });

And screenshots of how it works. 以及其工作原理的屏幕截图。 Please follow the ss. 请遵循ss。 在此处输入图片说明

在此处输入图片说明

From here this is solution from linke where is given by me up of issue. 从这里开始,这是我给出的链接中的解决方案。

Here code is my first work: 下面的代码是我的第一个工作:

 {
                        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");
                }
            });
        }
    });

And here how is work ss. 这是如何工作的。 It's show status on popup edit menu but it doesn't show on grid. 它在弹出编辑菜单上显示状态,但不在网格上显示。 在此处输入图片说明

please could you help me? 请你能帮我吗?

You're setting the checkbox in the template but not its value. 您正在模板中设置复选框,但未设置其值。 It will have always the initial state. 它将始终具有初始状态。 Try this template: 试试这个模板:

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

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM