Kendo ui复选框绑定

时间:2016-02-02 21:59:48

标签: asp.net linq kendo-ui kendo-grid

User Tab我有一个显示角色的Kendogrid。当您单击角色编辑时,它会打开一个包含多个选项卡的弹出窗口。在其中一个选项卡上我有用户。此选项卡显示所有用户的列表以及一个复选框,如果用户具有该角色,则会选中该复选框。  现在当我检查其他用户的复选框时,该角色必须为该用户分配并保存在数据库中。但是我如何在复选框的Onclick事件中调用服务中的方法,或者还有其他方法。

我得到的错误是当我点击复选框时它表示addRoleUsr()未定义。 addRoleUsr()在service.Below中定义。我的网格定义。

当我点击用户时,附加的图片必须保存在网格上。

由于

 function editEventGrid() {
        editDS = new kendo.data.DataSource({
            type: "json",
            schema: {
                data: function (response) {
                    return JSON.parse(response.d); // ASMX services return JSON in the following format { "d": <result> }. 
                },
                model: {// define the model of the data source. Required for validation and property types.
                    id: "UserId",
                    fields: {
                        FirstName: { editable: true, nullable: true, type: "string" },
                        UserId: { editable: true, nullable: false, type: "string" },
                        RoleId: { editable: false, nullable: false, type: "string" },
                            }
                },
            },
            transport: {
                read: {
                    url: "/Services/ErpNowServices.asmx/getUsersRoles", //specify the URL which data should return the records. This is the Read method of the Products.asmx service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "POST", //use HTTP POST request as the default GET is not allowed for ASMX
                    datatype: "json",
                    data: getSearchCriteria()
                },
                update: {
                    url: "/Services/ErpNowServices.asmx/UpdateUsers",
                    contentType: "application/json; charset=utf-8",
                    type: "POST",
                    datatype: "json"
                },
                parameterMap: function (data, type) {
                    if ((type == "read") || (type == "update") || (type == "destroy")) {
                        console.log('parameterMap: data => ' + JSON.stringify(data));
                        return JSON.stringify(data);                            
                    } else {
                        return data;
                    }
                }
            }
        });

        userGrid = $("#Users").kendoGrid({
            dataSource: editDS,
            height: 450,
            //dataBound: onDataBound,
            pageable: false,
            sortable: true,
            binding: true,
            serverFiltering: true,
            editable: "inline",
            autoSync: true,

            columns: [
               {
                 field: "FirstName",
                 title: "FirstName",
                 headerTemplate: '<span class="tbl-hdr">FirstName</span>',
                 attributes: {
                     style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
                 }
               },
                                 {
                   field: "UserId",
                   title: "UserId",
                   headerTemplate: '<span class="tbl-hdr">UserId</span>',
                   attributes: {
                       style: "vertical-align: top; text-align: left; font-weight:bold; font-size: 12px"
                   }
               },
               {

                   //title :"Check",
                   template: kendo.template("<input type='checkbox'  # if(RoleId){ # checked #} # onclick='addRoleUsr()'/>"),
                  // template: "<input type=\"checkbox\" # if(Rolename){ # checked #} # />",
                   attributes: {
                       style: "vertical-align: top; text-align: center;"
                   }
               },

        ],
            editable: true,
        }).data('kendoGrid');

}

0 个答案:

没有答案