The layui checkbox selection all loses the effect-soulTable

1, as shown

Question: When I select the check box in the title bar, the data check box in the data table is not selected, and the effect of selecting all is invalid
Insert picture description here

2. Code


  <div style="padding: 3px 0;">
      <table id="testlayuitable" lay-filter="testlayuitable"></table>
  </div>

  
  function business(data) {
    
    
        var table = layui.table;
        //第2个实例
        table.render({
    
    
            id: 'testlayuitable',
            elem: '#testlayuitable',
            height: CLIENTHEIGHT-60,
            size: 'sm' ,//小尺寸的表格
            page:true,
            limits:[15,30,50,100,200,500,1000,2000,5000,10000],
            limit:15,
            cols: [
                [  //标题栏
                    {
    
    type:'checkbox'}
                    ,{
    
    field: 'unitname', title: '名称',align:"left", minWidth: 260, sort: false, filter: true}
                    ,{
    
    field: 'unitcode', title: '代码',align:"center", minWidth: 80, sort: false, filter: true}
                ]
            ],
            data: data ? data : [],
            done: function () {
    
    
                layui.soulTable.render(this)
            }
        });
    }
    

3. Solve

Comparing the normal code, no exception was found. There is no other way but to copy the normal code.

Then replace the cols, after program comparison and screening, and finally find the problem

The culprit is layui.soulTable.render(this)

You use this plug-in, but it is not introduced, so it is not recognized, and an error will be reported. The solution is to delete the call or introduce the plug-in

3.1 Just delete it


 done: function () {
    
    
      //layui.soulTable.render(this)
  }
            

3.2 Or introduce the soulTable plugin


 layui.config({
    
    
        base: '/static/layui-v2.5.6/ext/',// 第三方模块所在目录
        version: 'v1.5.10' // 插件版本号
    }).extend({
    
    
        soulTable: 'soulTable/soulTable'
    });
    
    layui.use(['form','table','soulTable'], function() {
    
    
        searchBtn();//调用数据表格查询函数
    });
    

Guess you like

Origin blog.csdn.net/qq_36636312/article/details/112983076