我正在使用jQuery数据表,在我的表中,我按照表格第一列中的值进行分组,并在组中显示匹配的第一列的所有数据。我在每个组中都有“小计”行,我希望与分组行一起显示。以下是我的表现在的示例:
我想从'Subtotal'行获取单元格并将它们放在分组的行中。像这样:
这是我的数据表的当前代码:
$('#table').dataTable( {
"bFilter": true,
"aaSorting": [[ 5, "desc" ]],
"aaSortingFixed": [[ 0, "desc" ]],
"columnDefs": [
{ "visible": false, "targets": 0 }
],
"pageLength": 50,
"aoColumns": [
null,null, { "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num" },
{ "sSortDataType": "num-html", "sType": "formatted-num", "visible": false },
{ "sSortDataType": "num-html", "sType": "formatted-num", "visible": false },
{ "sSortDataType": "num-html", "sType": "formatted-num", "visible": false },
{ "sSortDataType": "num-html", "sType": "formatted-num", "visible": false }
],
"sDom": "CTlfrt<'container'<'pull-left'i><'pull-right'p>>",
"sPaginationType": "bootstrap",
"drawCallback": function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
api.column(0, {page:'current'} ).data().each( function ( group, i ) {
if ( last !== group ) {
$(rows).eq( i ).before(
"<tr class='group'><td colspan='"+18+"' style='background:#bcbcbc !important;'>"+group+"</td></tr>"
);
last = group;
}
} );
},
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
},
"oTableTools": {
"sSwfPath": "/public/swf/copy_csv_xls_pdf.swf",
"aButtons": [
"copy",
"print",
"csv"
]
},
} );
每当绘制表格时,我可以使用哪些Javascript来执行此操作?如果您需要更多信息,请与我们联系。
答案 0 :(得分:2)
答案 1 :(得分:0)
我的建议是使用jqGrid: jQuery Grid Plugin
在左侧面板中选择示例/在折叠上分组/查看摘要行
答案 2 :(得分:0)