我正在创建一个搜索模块,我可以使用复选框从结果中选择名称,我唯一的问题是我的复选框没有出现在显示结果的列上。 (参见图片以供参考)
<script>
$(document).ready(function() {
$('#searchTable').dataTable( {
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php echo site_url() ?>/search/get_account",
"sServerMethod": "GET",
"fnServerData": function ( sSource, aoData, fnCallback )
{
aoData.push( { "name": "txtClient", "value": "<?php echo $_POST["txtClient"]; ?>" } );
$.getJSON( sSource, aoData, function (json)
{
fnCallback(json)
} );
},
"aoColumns": [
{ "sTitle": "<input type='checkbox'></input>","mDataProp": null, "sWidth": "20px", "sClass ": "<input type='checkbox' ></input>", "bSortable": false }, //SELECT
{ "sClass": "centerAligned" , "bSortable" : false }, //CLIENT
{ "sClass": "centerAligned" , "bSortable" : false }, //PROD TYPE
{ "sClass": "centerAligned" , "bSortable" : false }, //REF ACCNT NO.
{ "sClass": "centerAligned" , "bSortable" : false }, //VALUE DATE
{ "sClass": "centerAligned" , "bSortable" : false }, //MATURITY DATE
{ "sClass": "centerAligned" , "bSortable" : false }, //CCY
{ "sClass": "leftAligned" , "bSortable" : false }, //PRINCIPAL
{ "sClass": "leftAligned" , "bSortable" : false }, //RATE (%)
{ "sClass": "leftAligned" , "bSortable" : false }, //MATURITY AMNT
]
} );
} );
</script>
答案 0 :(得分:0)
尝试这样做:
"aoColumns": [
{ "sTitle": "<input type='checkbox' class = 'chk'></input>","mDataProp": null, "sWidth": "20px", "sClass ": "<input type='checkbox' class = 'chk'></input>", "bSortable": false }, //SELECT
{ "sClass": "centerAligned" , "bSortable" : false }, //CLIENT
{ "sClass": "centerAligned" , "bSortable" : false }, //PROD TYPE
{ "sClass": "centerAligned" , "bSortable" : false }, //REF ACCNT NO.
{ "sClass": "centerAligned" , "bSortable" : false }, //VALUE DATE
{ "sClass": "centerAligned" , "bSortable" : false }, //MATURITY DATE
{ "sClass": "centerAligned" , "bSortable" : false }, //CCY
{ "sClass": "leftAligned" , "bSortable" : false }, //PRINCIPAL
{ "sClass": "leftAligned" , "bSortable" : false }, //RATE (%)
{ "sClass": "leftAligned" , "bSortable" : false }, //MATURITY AMNT
]
在document.ready()
尝试做这样的事情:
$(".chk").html("<input class='chk' type='checkbox'>");
答案 1 :(得分:0)
我已经在这个问题上得到了答案,抱歉我认为我的问题在视图中,但事实证明问题出在模型中,所以我只是在我的变量中添加它。
"<input type='checkbox' name='checkbox".$i."' id='checkbox".$i."' value='".$row->print."' />",
而不是
$row->print,