forked from fernandommota/addin-datatable-grand-total
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postExecution.js
39 lines (33 loc) · 1.01 KB
/
postExecution.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function postExecution() {
$("#" + this.htmlObject + "Table")
.parent()
.addClass("table-responsive");
var tableId = "#" + this.htmlObject + "Table";
var tableColumnSize = $(tableId + " th").length;
var tableColumnGrandTotalSize = $(tableId + " th.datatableGrandTotal").length;
var tableColumncolspan = tableColumnSize - tableColumnGrandTotalSize;
var tfootTemplate =
"<tfoot>" +
'<tr class="datatable-total">' +
"<td>Total</td>{{tdTotal}}" +
"</tr>" +
'<tr class="datatable-grand-total">' +
"<td>Grand Total</td>{{tdGrandTotal}}" +
"</tr>" +
"</tfoot>";
var tdTotal = "";
var tdGrandTotal = "";
for (var i = 0; i < tableColumnSize - 1; i++) {
tdTotal += "<td></td>";
tdGrandTotal += "<td></td>";
}
tfootTemplate = tfootTemplate
.replace("{{tdTotal}}", tdTotal)
.replace("{{tdGrandTotal}}", tdGrandTotal);
$(tableId).append(tfootTemplate);
//force the render of table
$(tableId + "_filter input")
.val(" ")
.keyup()
.val("");
}