layui 复选框选择性加载

layui 复选框

效果图

      table.render({
                       elem: '#tableData'
                      , url: '/rxcameramanager/pageQuery'
                      , method: 'post'
                   
                      , cols: [[
                        {   //这里使用layui给我们提供的自定义模版功能来达到checkbox控制效果
                 field:'CheckCustom' ,title:'复选框',width:70,templet:function (d) {
                                   //记录当前数据渲染的是第几行
                                   var dIndex = d.LAY_TABLE_INDEX;
                                   //给每一个checkbox加一个id
                                   var id = 'ck'+dIndex;
                                   var templateHtml = ' <input type="checkbox" id="'+id+'" class="layui-input layui-form-checkbox" lay-skin="primary"lay-filter="ldEvent"><i class="layui-icon"></i>';
                                   //利用三元表达式判断本条数据是否需要加载checkbox
                                   return (d.status=="-99")?'':templateHtml
                              }
                          },

                          {type: 'checkbox', fixed: 'left'}
                          , {type: 'numbers', title: '序号'}
                          , {field: 'displayName', minWidth: 90, title: '名称'}
                          , {field: 'cameraType', minWidth: 90, title: '视频源类型' , templet: '#cameraTypes'}
                          , {field: 'zoneName', minWidth: 90, title: '分组'}
                          , {field: 'isOnline', minWidth: 90, title: '连接情况', templet: '#onLine'}
                          , {field: 'accessStatus', minWidth: 90, title: '接入状态', templet: '#accStatus'}
                          , {field: 'status', minWidth: 90, title: '相机状态',templet: '#cameraStatus'}
                          , {title: '操作', align: 'center', minWidth: 150, fixed: 'right', toolbar: '#table-face-db'}
                      ]]
                      , page: true
                      , limit: 10
                      , limits: [10, 20, 30, 40, 50 ,100,200,300]
                      , text: {none: '暂无数据'}
                      , done: function () {
                           element.render('progress')
                      }
                  });
           {   //这里使用layui给我们提供的自定义模版功能来达到checkbox控制效果
                 field:'CheckCustom' ,title:'复选框',width:70,templet:function (d) {
                     //记录当前数据渲染的是第几行
                     var dIndex = d.LAY_TABLE_INDEX;
                      //给每一个checkbox加一个id
                      var id = 'ck'+dIndex;
                      var templateHtml = ' <input type="checkbox" id="'+id+'" class="layui-input layui-form-checkbox" lay-skin="primary"lay-filter="ldEvent"><i class="layui-icon"></i>';
                       //利用三元表达式判断本条数据是否需要加载checkbox
                       return (d.status=="-99")?'':templateHtml
                              }
                          },



posted @ 2021-04-14 15:03  Java不香吗  阅读(358)  评论(0)    收藏  举报