复选框未选中且rowCallback无法响应数据表

时间:2015-12-03 11:47:31

标签: jquery checkbox responsive-design datatables

我正在使用数据表和响应式扩展,我有一些复选框,表示我的数据库中的布尔数据(0,1)。我使用rowCallback data来检查复选框。但是当页面调整大小或处于响应模式时,它会将列显示为子列表,详细列表,未选中复选框并且未触发rowCallback且数据未定义..!

        table=$('#mytable').DataTable({
        "sDom": "<'row DTTTHeader'<'col-sm-7'Tl><'col-sm-5 no-padding'f>>t<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>",
        processing: true,
        serverSide: false,
        deferRender: true,
        responsive: true,                                   
        ajax: {
            url: '/my/url/show',
            method: 'POST',                  

        },
        columns: [
            {data: "id", searchable: false, visible: false, className: "never"},
            {data: "product", searchable: true, visible: true},
            {data: "category", searchable: true, visible: true},
            {data: "available", searchable: true, visible: true},
            {data: "sold", searchable: true, visible: true},
            {data: "active", searchable: false,
                render: function ( data, type, row ) {
                    if ( type === 'display' ) {
                        return '<label><input class="checkbox colored-danger active" type="checkbox" disabled><span class="text"></span></label>';
                    }
                    return data;
                }, 
                className: "dt-center"                       
            }
            {
              data: null,
              defaultContent: '<button class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> edit</button> <button class="btn btn-danger btn-xs del" data-toggle="modal" data-target="#modal-danger"><i class="fa fa-trash-o"></i> remove</button>',
              targets: -1 ,
              searchable: false,
              orderable: false,
            }          
        ],
        rowCallback: function ( row, data ) {
            $('input.active', row).prop( 'checked', data.active == 1 );
        }                    
    }); 
由于未定义的行data.iddata.active

按钮和复选框无效

的jsfiddle http://jsfiddle.net/s95q26pn/4/

信息:尝试调整窗口大小以查看数据表的响应模式,然后检查第2行,例如,当它应该是

时,不检查活动复选框

0 个答案:

没有答案