我希望在选中复选框时,通过复选框的值显示数据。如果该值是一个信用额,显示列名称详细信息中包含信用的所有行,依此类推。所以我的问题是如何只在单击复选框并进行检查时显示数据?我想只显示详细信息列具有值“credit”的行
视图:
<input type="checkbox" id="credit" value="credit" >
<table id="users-table">
<thead>
<tr>
<td>Details</td>
<td>Date</td>
<td>Description</td>
</tr>
</thead>
</table>
阿贾克斯
<script type="text/javascript">
$(function() {
$('#users-table').DataTable({
processing: true,
serverSide: true,
ajax: 'student/get_datatable',
columns : [
{data: 'details'},
{data: 'Date'},
{data: 'Description'},
],
pageLength: 5,
});
});
</script>
调节器
public function get_datatable()
{
return Datatables::eloquent(Checks::query())->make(true);
}
在列中使用渲染回调函数。 喜欢:
columns: [
{
data: 'details'
"render": function (url, type, full) {
if(condition == true){
return 'something';
}else{
return 'something else';
}
}
}
]
在渲染中,您可以返回用于创建复选框的字符串,如:
"render": function (url, type, full) {
return '<input type="checkbox">';
}
希望这可以帮助。