AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
# 关于多选框的冻结方法 ## **问题** 官方提供的方法无法冻结checkbox ## **思路** 隐藏官方的checkbox ,自定义checkbox 列 ## **代码** 1、隐藏官方的checkbox ,用checkbox:false, 属性 ~~~ vm.GridOptions = vm.kendoGrid.init({                 id: 'Tables',                 checkbox:false,                 model: {                     fields: {                     }                 },                 columns: vm.getColumns()             }); ~~~ 2、冻结相关列、添加checkbox列,使用 locked: true,属性 ~~~ var nColumns = [{                 title: "<input type='checkbox' id='chkSelectAll' ng-click='vm.selectAllRow(this)'  />",                 field: 'id',                 width: 50,                 filterable: false,                 sortable: false,                 locked: true,                 headerAttributes: { style: "text-align: center;" },                 attributes: { style: 'text-align: center;' },                 template: function (dataItem) {                     return '<input type="checkbox" id="gcheckbox" class="gcheckbox" />';                 }             }, {                 title: ‘冻结列’,                 width: 80,                 locked: true,                 headerAttributes: { style: "text-align: center;" },                 attributes: { style: 'text-align: center;' },                              } ~~~ 3、添加全选方法 ~~~ vm.selectAllRow = function (ele) {             var state = $("#chkSelectAll").is(':checked');             console.dir(state);             if (state) {                 $(".gcheckbox").each(function () {                     //console.dir(this);                     $(this).prop("checked", true); //此处设置每行的checkbox选中,必须用prop方法                     $(this).closest("span").addClass("checked");                      $(this).closest("tr").addClass("k-state-selected");  //设置grid 每一行选中                 });             } else {                 $(".gcheckbox").each(function () {                     $(this).prop("checked", false);                     $(this).closest("span").removeClass("checked");                      $(this).closest("tr").removeClass("k-state-selected");  //设置grid 每一行选中                 });             }         } ~~~