在我的页面中,有一组四个字段可以在数据库中自定义search
个记录;结果将显示在DataTable
内,该<script type="text/javascript">
$(document).ready(function() {
var j_table = $("#t_list").dataTable( {
"oLanguage" : {
"sInfoThousands": " ",
"sEmptyTable" : _getText("datatable_resultat_zero", "global"),
"sInfo" : _getText("datatable_zone_statut_info", "global"),
"sInfoEmpty" : "",
"sInfoFiltered" : _getText("datatable_zone_statut_filtre", "global"),
"sLengthMenu" : _getText("datatable_zone_nb_affichage", "global"),
"sSearch" : _getText("datatable_zone_filtre", "global"),
"sZeroRecords" : _getText("datatable_resultat_zero", "global"),
"oPaginate" : {
"sPrevious" : _getText("datatable_btn_prcdt", "global"),
"sNext" : _getText("datatable_btn_svt", "global")
}
},
"sPaginationType" : "bootstrap",
"aoColumnDefs": [
{ "aTargets": [ 3 ], "bSortable": false },
{ "aTargets": [ 3 ], "bSearchable": false },
{
"aTargets": [ 3 ],
"mRender": function ( data, type, full ) {
return '<div style="text-align: center;"><a href="<?php echo site_url('meeting/modif'); ?>/'+data+'" title="Modifier"><button class="btn btn-mini">Detail</button></a></div>';
}
}
],
"bServerSide": true,
"sAjaxSource": "<?php echo site_url('ajax/dataTableListerMeetingNotes'); ?>",
"sServerMethod": "POST"
} );
});
</script>
显示在这些字段组下方:
以下是DataTable的javascript创建:
DataTable
那么当点击&#34; Valider&#34;时,如何将四个字段中输入的值传递给script
的ajax源。蓝色按钮?以及如何在DataTable ajax
调用的@Component({
... // your settings
})
export class MyComponent {
myFuncThatReturnsBoolean(): boolean {
// If you need some logic to determine
// whether to turn it on or off, do it here
// otherwise
return false;
}
}
内收集这些数据?
答案 0 :(得分:3)
将其添加到初始化代码中,每次调用fnDraw()
时,参数都将在数据表请求中传递。显然,您必须更改jquery选择器以匹配您的输入ID。
"sServerMethod": "POST",
"fnServerParams": function (aoData) {
aoData.push({ "name": "sujet", "value": $('#Sujet').val() });
aoData.push({ "name": "lieu", "value": $('#Lieu').val() });
aoData.push({ "name": "dateDu", "value": $('#DateDu').val() });
aoData.push({ "name": "dateAu", "value": $('#DateAu').val() });
},
在Valider
按钮点击事件中,您拨打j_table.fnDraw()
在服务器端,您以与标准数据表参数相同的方式访问参数,即从查询字符串中获取:
$_POST['sujet']
我不熟悉PHP,但它会是这样的。