无法向Kendo UI网格添加单选按钮

时间:2013-02-05 20:45:45

标签: templates radio-button kendo-ui kendo-grid

我正在尝试在我的Kendo网格中有一组3个单选按钮(每个按钮位于不同的列但是同一行),但没有成功。我查看了Kendo RowTemplate文档,但它没有指导我任何解决方案。 它可以与复选框一起使用,但是当我将模板更改为“radio”类型时,它会更改为复选框,第二次单击编辑按钮。有什么想法吗? 下面是我的kendoGrid属性,我把**放在字段属性的'template'行旁边。

div.kendoGrid({
                    dataSource:
                    {   error: function (e) {
                                    alert("An error occured: "+ e.xhr.responseText);
                                    this.cancelChanges();
                                },
                        type:"json",
                        transport: {
                            read: {
                                url: "/users/read",
                                cache: false,                        
                                dataType: "json"
                            },
                            update: {
                                url: function(user){
                                    var grid = $("#grid").data("kendoGrid");
                                    var model = grid.dataItem(grid.select());
                                    var roleIs;
                                    if (user.Admin) {
                                        roleIs="admin"
                                    }
                                    else if (user.Manager) {
                                        roleIs="manager"
                                    }
                                    else if (user.User) {
                                        roleIs="user"
                                    };
                                    return  "users/update/"+model.id+"/"+roleIs+"/"+user.name
                                },
                                type: "PUT"
                            },
                            destroy: {
                                url: function(user){
                                    return  "/users/destroy/"+user.id+"/"+user.name
                                    },
                                    type: "DELETE"
                            },
                            create: {
                                url: function(user){

                                    var roleIs;
                                    if (user.Admin) {
                                        roleIs="admin"
                                    }
                                    else if (user.Manager) {
                                        roleIs="manager"
                                    }
                                    else if (user.User) {
                                        roleIs="user"
                                    };
                                    return  "users/create/"+user.login+"/"+user.name+"/"+roleIs+"/"
                                },
                                type: "POST"
                            },
                            parameterMap: function(options, operation) {
                                if (operation !== "read" && options.models) {
                                    return {models: kendo.stringify(options.models)};
                                }
                            }
                        },
                        schema: {

                            model: 
                            { id: "id",
                                fields: {
                                    id:{ type: "number",editable: false},
                                    role:{ type: "string"},
                                    login: { type: "string",editable: false},
                                    name:{type: "string",editable: false},
                                    Admin: { type: "boolean"},
                                    Manager: { type: "boolean"},
                                    User: { type: "boolean"}
                                }
                            }
                        },
                        pageSize: 30,
                        serverPaging: false,
                        serverFiltering: false,
                        serverSorting: false
                    },

                    selectable: "row",
                    navigatable: true,
                    pageable: true,
                    height: 400,
                    columns: [//{field: "id"},
                        {
                        field: "name",
                        title:"User Name",
                        filterable: true,
                        nullable: false,
                        editable: false
                        },{
                            field: "Admin",
                            **template: '<input type="checkbox"  #= Admin ? "checked=checked" : "" # disabled="disabled"></input>'**,
                            width: 75
                        },{
                            field: "Manager",
                            **template: '<input type="checkbox"  #= Manager ? "checked=checked" : "" # disabled="disabled"></input>'**,
                            width: 75
                        },{
                             field: "User", 
                             **template: '<input type="checkbox"  #= User ? "checked=checked" : "" # disabled="disabled"></input>',**
                             width: 75
                        },{
                             command: ["edit", "destroy"], title: "", width: "195px"
                        }],
                    editable:{mode: "inline"} 
                });
    }
}

}

1 个答案:

答案 0 :(得分:0)

版本格式由columns.editor

控制

您需要编写一个编辑器函数,将input定义为单选按钮。