附加;为了按组显示数据,每组以 1 个数字开始
我很困惑如何正确呈现数据表。 我的html代码是
<table id="EmployeeGrid" class="table table-bordered table-striped">
<thead>
<tr>
<th colspan="6"><i class="fas fa-user"></i> Employee Info</th>
<th colspan="5"><i class="fas fa-file"></i> Contract Info</th>
</tr>
<tr>
<th>IR No.</th>
<th>Name</th>
<th>Job Title</th>
<th>NIC</th>
<th>Location</th>
<th>Project</th>
<th>DOJ</th>
<th>Status</th>
<th>St. Date</th>
<th>End Date</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr><th colspan="12"></th></tr>
</tbody>
</table>
在html预定义标题中。相当于通过 jQuery 渲染。
我的 jQuery 代码
var DataGrid = $('#EmployeeGrid');
var url = "{{url('employees/search')}}";
var dataTable = DataGrid.DataTable({
dom: "Tlfrtip",
aaSorting: [], //disabled initial sorting
ajax: url,
paging: true,
searching: false,
info: true,
autoWidth: false,
responsive: true,
processing: true,
serverSide: true,
ordering: true,
lengthMenu: [[10,25, 50, 100, 200, 500, 1000], [10,25, 50, 100, 200, 500, 1000]],
pageLength: 10,
LengthChange: false,
"scrollX": true,
/*"columnDefs": [
{"width": "10%", "targets": 4, "class":'word-wrap'},
],*/
columns: [
//Table Column Header Collection
{data: "irp_number"},
{
data: null, render: function (data, type, row) {
var url_edit = "{{url('employees/edit_view')}}";
return '<a href="'+url_edit+'/'+data.employee_id+'" data-id="'+data.employee_id+'" data-toggle="tooltip" data-placement="bottom" title="Edit & View Employee">'+data.employee_name+'</a>'
}
},
{data: "empDesignation"},
{data: "cnic"},
{data: "empDutyStation"},
{data: "empGender"},
{data: "empIRJoiningDate"},
{data: "empStatus"},
{data: "empIRJoiningDate"},
{data: "empIRJoiningDate"},
{data: "employment_type"}
],
});
非常完美。
我的问题是如何追加新部门:data.depName 因为我想按它和 1,2,3...n 的 strat 系列进行分组。下一组 1,2,3...n 就像这样如图所示: https://datatables.net/examples/advanced_init/row_grouping.html
I am confuse how to render data table properly.
my html code is
<table id="EmployeeGrid" class="table table-bordered table-striped">
<thead>
<tr>
<th colspan="6"><i class="fas fa-user"></i> Employee Info</th>
<th colspan="5"><i class="fas fa-file"></i> Contract Info</th>
</tr>
<tr>
<th>IR No.</th>
<th>Name</th>
<th>Job Title</th>
<th>NIC</th>
<th>Location</th>
<th>Project</th>
<th>DOJ</th>
<th>Status</th>
<th>St. Date</th>
<th>End Date</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr><th colspan="12"></th></tr>
</tbody>
</table>
In html pre define header. equivalent to which is rendering by jQuery.
My jQuery code is
var DataGrid = $('#EmployeeGrid');
var url = "{{url('employees/search')}}";
var dataTable = DataGrid.DataTable({
dom: "Tlfrtip",
aaSorting: [], //disabled initial sorting
ajax: url,
paging: true,
searching: false,
info: true,
autoWidth: false,
responsive: true,
processing: true,
serverSide: true,
ordering: true,
lengthMenu: [[10,25, 50, 100, 200, 500, 1000], [10,25, 50, 100, 200, 500, 1000]],
pageLength: 10,
LengthChange: false,
"scrollX": true,
/*"columnDefs": [
{"width": "10%", "targets": 4, "class":'word-wrap'},
],*/
columns: [
//Table Column Header Collection
{data: "irp_number"},
{
data: null, render: function (data, type, row) {
var url_edit = "{{url('employees/edit_view')}}";
return '<a href="'+url_edit+'/'+data.employee_id+'" data-id="'+data.employee_id+'" data-toggle="tooltip" data-placement="bottom" title="Edit & View Employee">'+data.employee_name+'</a>'
}
},
{data: "empDesignation"},
{data: "cnic"},
{data: "empDutyStation"},
{data: "empGender"},
{data: "empIRJoiningDate"},
{data: "empStatus"},
{data: "empIRJoiningDate"},
{data: "empIRJoiningDate"},
{data: "employment_type"}
],
});
this works perfect.
My Question is how to append new Dept : data.depName
as i want to group by it and strat series from 1,2,3...n. next group 1,2,3...n
like this as shown in figure:
https://datatables.net/examples/advanced_init/row_grouping.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论