Jquery datatables 将mRender与datatables和css一起使用不在处理?

Jquery datatables 将mRender与datatables和css一起使用不在处理?,jquery-datatables,Jquery Datatables,我正在使用mRender在tbody的第一列中添加复选框。。。正在应用正确的css样式,但在我查看表时,这些样式没有被样式化。我只能假设这是因为我使用mRender来添加这些值,然而,如果我使用其他css,比如更改文本的颜色,它就可以正常工作。我对thead中的复选框的样式设置没有问题,但是默认情况下,它包含在html中。想法 html: <table class="table table-striped table-bordered table-hover" id="sample_1"&

我正在使用mRender在tbody的第一列中添加复选框。。。正在应用正确的css样式,但在我查看表时,这些样式没有被样式化。我只能假设这是因为我使用mRender来添加这些值,然而,如果我使用其他css,比如更改文本的颜色,它就可以正常工作。我对thead中的复选框的样式设置没有问题,但是默认情况下,它包含在html中。想法

html:

<table class="table table-striped table-bordered table-hover" id="sample_1">
<thead>
    <tr>
        <th><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
        <th>Username</th>
        <th>Password</th>
        <th>Email</th>
    </tr>
</thead>
<tbody>
    <tr class="odd gradeX">
        <td>Data 1</td>
        <td>Data 2</td>
        <td>Data 3</td>
        <td>Data 4</td>
    </tr>
</tbody>
</table>

用户名
密码
电子邮件
数据1
数据2
数据3
数据4
js:

$('#sample_1').dataTable({
//start my code
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/assets/data-tables/test-normal.php",
//end my code
"aLengthMenu": [
    [5, 15, 20, -1],
    [5, 15, 20, "All"] // change per page values here
],
"aoColumnDefs": [ {
    "aTargets": [ 0 ],
    "bSortable": false,
    "mRender": function ( data, type, full ) {
        return '<input type="checkbox" class="checkboxes" value="'+data+'" />';
    }
} ],
// set the initial value
"iDisplayLength": 5,
"sPaginationType": "bootstrap",
"oLanguage": {
    "sLengthMenu": "_MENU_ records",
    "oPaginate": {
        "sPrevious": "Prev",
        "sNext": "Next"
    }
},
});
$('#示例1')。数据表({
//启动我的代码
“bProcessing”:正确,
“bServerSide”:正确,
“sAjaxSource”:“/assets/data tables/test normal.php”,
//结束我的代码
“阿伦哲努”:[
[5, 15, 20, -1],
[5,15,20,“全部”]//此处更改每页的值
],
“aoColumnDefs”:[{
“目标”:[0],
“可移植”:错误,
“mRender”:功能(数据、类型、完整){
返回“”;
}
} ],
//设置初始值
“iDisplayLength”:5,
“sPaginationType”:“引导程序”,
“语言”:{
“长菜单”:“长菜单记录”,
“oPaginate”:{
“以前的”:“以前的”,
“sNext”:“下一步”
}
},
});

您错过了mData部分

在aoColumns而不是aoColumnDefs中,使用以下命令

{ "mData": null , // can use null, the numeric array number, or assoc array string
     "mRender" : function ( data, type, full ) { 
        return '<input type="checkbox" class="checkboxes" value="'+data+'" />'}
      },
{“mData”:null,//可以使用null、数字数组编号或assoc数组字符串
“mRender”:函数(数据、类型、完整){
返回“”}
},

您错过了mData部分

在aoColumns而不是aoColumnDefs中,使用以下命令

{ "mData": null , // can use null, the numeric array number, or assoc array string
     "mRender" : function ( data, type, full ) { 
        return '<input type="checkbox" class="checkboxes" value="'+data+'" />'}
      },
{“mData”:null,//可以使用null、数字数组编号或assoc数组字符串
“mRender”:函数(数据、类型、完整){
返回“”}
},
必须使用:

"fnInitComplete": function() {
    $(".checkboxes").uniform();
}
必须使用:

"fnInitComplete": function() {
    $(".checkboxes").uniform();
}

这也解决不了问题。我上面的代码完全按照预期工作,但由于某些原因,tbody内的复选框上没有样式。使用firebug,json是正确的,输出是正确的,css是正确的。我实际上可以将其更改为返回“”+数据+”;它会以红色文本显示id。不过,复选框样式上没有任何问题。请提供一段代码,我很乐意帮助您解决这个问题。从发布的代码中,我看不出有什么小问题,所以这也解决不了问题。我上面的代码完全按照预期工作,但由于某些原因,tbody内的复选框上没有样式。使用firebug,json是正确的,输出是正确的,css是正确的。我实际上可以将其更改为返回“”+数据+”;它会以红色文本显示id。不过,复选框样式没有任何问题。请提供一段代码,我很乐意帮助您解决这个问题,从目前发布的代码来看,这是一个很小的问题