如何在数据表中的每一列上使用复选框? [英] How to employ check-boxes on each column in data-table ?
本文介绍了如何在数据表中的每一列上使用复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
我需要在数据表中执行删除批处理操作。在做任何事情之前,我需要在每一行的第一列上设置一个复选框。因此,当我检查多个时,用户可以在按钮单击时删除这些行。
感谢任何链接或建议
关注
Hi
i need to do a batch action of delete in my data-table . before doing anything i need a check box on column one of every row . so when i check multiple , user can delete those rows on button click.
Any links or suggestions are appreciated
Regards
推荐答案
使用mRender
Using mRender
( document )。ready( function (){
var oTable =
(document).ready(function () { var oTable =
(' #example')。dataTable( {
aoColumnDefs:[{
aTargets:[ 0 ],
// mData:download_link,
mRender: function (数据,类型,完整){
if (data == Gecko){
return ' < a href =' + data + ' >' + data + ' 下载Gecko< / a> 跨度>;
} 其他 {
返回 ' < a href =' + data + ' >' + data + ' 下载< / a>' ;
}
}
},{
aTargets:[ 1 ],
// mData:download_link,
mRender:< span class =code-keyword> function (数据,类型,完整){
if (data == 1){
return ' < input type = \checkbox \checked value =' + data + ' >';
} 其他 {
返回 ' < input type = \checkbox \value =' + data + ' >';
}
}
},{
aTargets:[ 2 ],
// mData:download_link,
mRender:< span class =code-keyword> function (数据,类型,完整){
if (data == 1){
return ' < input type = \checkbox \checked value =' + data + ' >';
} 其他 {
返回 ' < input type = \checkbox \value =' + data + ' >';
}
}
},{
aTargets:[ 3 ],
// mData:download_link,
mRender:< span class =code-keyword> function (数据,类型,完整){
if (data == 1){
return ' < input type = \checkbox \checked value =' + data + ' >';
} 其他 {
返回 ' < input type = \checkbox \value =' + data + ' >';
}
}
},{
aTargets:[ 4 ],
// mData:download_link,
mRender:< span class =code-keyword> function (数据,类型,完整){
if (data == 1){
return ' < input type = \checkbox \checked value =' + data + ' >';
} 其他 {
返回 ' < input type = \checkbox \value =' + data + ' >';
}
}
}
],
bFilter: false ,
sScrollY: 500px,
< span class =code-string> bPaginate: false ,
b处理: true ,
sAjaxSource: sources / sample.json
});
});
('#example').dataTable({ "aoColumnDefs": [{ "aTargets": [0], //"mData": "download_link", "mRender": function (data, type, full) { if (data == "Gecko") { return '<a href="' + data + '">' + data + ' Download Gecko</a>'; } else { return '<a href="' + data + '">' + data + ' Download</a>'; } } }, { "aTargets": [1], //"mData": "download_link", "mRender": function (data, type, full) { if (data == "1") { return '<input type=\"checkbox\" checked value="' + data + '">'; } else { return '<input type=\"checkbox\" value="' + data + '">'; } } }, { "aTargets": [2], //"mData": "download_link", "mRender": function (data, type, full) { if (data == "1") { return '<input type=\"checkbox\" checked value="' + data + '">'; } else { return '<input type=\"checkbox\" value="' + data + '">'; } } }, { "aTargets": [3], //"mData": "download_link", "mRender": function (data, type, full) { if (data == "1") { return '<input type=\"checkbox\" checked value="' + data + '">'; } else { return '<input type=\"checkbox\" value="' + data + '">'; } } }, { "aTargets": [4], //"mData": "download_link", "mRender": function (data, type, full) { if (data == "1") { return '<input type=\"checkbox\" checked value="' + data + '">'; } else { return '<input type=\"checkbox\" value="' + data + '">'; } } } ], "bFilter": false, "sScrollY": "500px", "bPaginate": false, "bProcessing": true, "sAjaxSource": "sources/sample.json" }); });
这篇关于如何在数据表中的每一列上使用复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文