Bhu*_*oni 5 php datatable laravel
我在laravel项目中使用数据表.需要从数据库中获取记录,它可能是两个点.如何使用rowspan或colspan来创建具有分页和pageLength功能的记录类别组?
该项目致力于laravel框架5.5.php> = 7.0版本和MySQL 5.0.
我也尝试过rowGroup的数据表.但它有一些限制,如:
- 目前一次只能使用一个数据点进行分组 - 不支持嵌套分组
- 无法扩展/折叠组的选项
- 不支持Buttons扩展的导出选项 - 只是忽略分组信息.
var table = $('#report-employee-table').DataTable({
pageLength: 20,
processing: true,
serverSide: true,
bLengthChange: false,
dom: 'Blfrtip',
buttons: [{
extend: 'excelHtml5',
"text": '<span class="glyphicons glyphicons-file_export"></span> Export',
"title": 'Employee Report',
"message": 'Employee Name: ' + $('#employee_id option:selected').text() + ' Work Duration: ' + $('#report_date').val(),
"filename": 'employee-report',
header: true,
footer: true,
exportOptions: {
modifier: {
selected: true
}
},
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
// s = for styling and 5 will make it left align with grey background
$('row:first c', sheet).attr('s', '5');
}
},
{
extend: 'print',
"text": '<span class="fa fa-print"></span> Print',
"title": 'Employee Report',
"message": 'Employee Name: ' + $('#employee_name option:selected').text() + ' Work Duration: ' + $('#report_date').val(),
"filename": 'employee-report',
header: true,
footer: true,
exportOptions: {
modifier: {
selected: true
}
}
}
],
ajax: {
url: "/*URL of controller where function return data in json format*/",
data: function (d) {
d.employee_name = $('#employee_name').val();
d.report_date = $('#report_date').val();
}
},
columns: [
//{data: 'DT_Row_Index', name: 'DT_Row_Index'},
{
data: 'project_name',
name: 'project_name'
},
{
data: 'work_type_name',
name: 'work_type_name'
},
{
data: 'total_hour',
name: 'total_hour'
},
],
rowsGroup: ['project_name:name', 0],
footerCallback: function (row, data, start, end, display) {
var api = this.api();
var aCol = api.column(2);
var foo = aCol.data(); //is empty!
$(aCol.footer()).html(
);
},
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
206 次 |
| 最近记录: |