$(document).ready(function () {
function tax_type(x) {
return (x == 1) ? "<?=lang('percentage')?>" : "<?=lang('fixed')?>";
}
oTable = $('#CURData').dataTable({
"aaSorting": [[2, "asc"], [3, "asc"]],
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "<?= lang('all') ?>"]],
"iDisplayLength": <?= $Settings->rows_per_page ?>,
'bProcessing': true, 'bServerSide': true,
'sAjaxSource': '<?= admin_url('system_settings/mapLocations') ?>',
'fnServerData': function (sSource, aoData, fnCallback) {
aoData.push({
"name": "<?= $this->security->get_csrf_token_name() ?>",
"value": "<?= $this->security->get_csrf_hash() ?>"
});
$.ajax({'dataType': 'json', 'type': 'POST', 'url': sSource, 'data': aoData, 'success': fnCallback});
},
"aoColumns": [{"bSortable": false, "mRender": checkbox}, { "bSortable": false, "mRender": img_hl }, null, null, null, null, null, null]
}).fnSetFilteringDelay().dtFilter([
{column_number: 2, filter_default_label: "[<?=lang('code');?>]", filter_type: "text", data: []},
{
column_number: 3,
filter_default_label: "[<?=lang("name");?>]",
filter_type: "text", data: []
},
{
column_number: 4,
filter_default_label: "[<?=lang("phone");?>]",
filter_type: "text", data: []
},
{
column_number: 5,
filter_default_label: "[<?=lang("email");?>]",
filter_type: "text", data: []
},
{
column_number: 6,
filter_default_label: "[<?=lang("address");?>]",
filter_type: "text", data: []
},
], "footer");
});
如上图所示。我需要选中状态为1的复选框。 如何使用数据表
数据表数据是在加载时从数据库中检索的。
我同时上传了HTML和Javascript代码。
答案 0 :(得分:0)
问题现在已解决。感谢Viewer。
解决方案如下。我更新了“ mRender”并为我的自定义复选框创建了功能
"aoColumns": [{"bSortable": false, "mRender": function ( data, type, row ) {
var location= [<?php echo '"'.implode('","', $map_location).'"' ?>];
if(jQuery.inArray( data, location )==-1){
return '<div class="text-center"><input class="checkbox multi-select" type="checkbox" name="val[]" value="' + data + '" /></div>';
}
else{
return '<div class="text-center"><input checked class="checkbox multi-select" type="checkbox" name="val[]" value="' + data + '" /></div>';
}
//return '<div class="text-center"><input class="checkbox multi-select" type="checkbox" name="val[]" value="' + data + '" /></div>';
}
}, { "bSortable": false, "mRender": img_hl }, null, null, null, null, null]