前端UI框架ligerui表格汇总功能⽆法计算全部数据的合计的解
决⽅法
想做⼀个⼯资表,下⾯带各列数据的汇总,恰巧ligerui有汇总功能,但是只能对当前页⾯显⽰数据求和,毕竟前台js计算数据不是强项,还是应该post从后台取汇总数据。
先看看js代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE HTML>
<html>
<head>
<title>表格控件 - 固定列</title>
<link href="${tPath}/static/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
<script src="${tPath}/static/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="${tPath}/static/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="${tPath}/static/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
<script src="${tPath}/static/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
<script src="${tPath}/static/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
<script src="${tPath}/static/CustomersData.js" type="text/javascript"></script>
<script type="text/javascript">
var g;
let test;
$(function ()
{
$.post("${tPath}/book/salaryobj",function (data) {
//console.log(data)
const data1 = JSON.parse(data);
//const data1 = {Rows:obj,totalvalue:1001}
console.log(data1)
g = $("#maingrid4").ligerGrid({
columns: [
{display: '编号', name: 'personID', width: 60, frozen: true, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
return '<div>总数:' + data1.Total.personID + '</div>';
}
}
} ,//align: 'left',
{ display: '姓名', name: 'name', width: 60, frozen: true }, //minWidth
{ display: '部门', name: 'department', width: 90, frozen: true }, //, frozen: true , align: 'left'                        { display: '年', name: 'yyyy', width: 60 , frozen: true },//, align: 'left'
{ display: '⽉', name: 'mm', width: 60, frozen: true }, //, align: 'left' , frozen: true
{ display: '⽇', name: 'dd', width: 60, frozen: true, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>合计:</div>';
}
}
},
{ display: '基本⼯资', name: 'base', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.base + '</div>';
}
}
},
{ display: '岗位⼯资', name: 'post', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.post + '</div>';
}
}
},
{ display: '⼯龄⼯资', name: 'workingAge', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.workingAge + '</div>';
}
}
},
{ display: '学历⼯资', name: 'education', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.education + '</div>';
}
}
},
{ display: '独⽣⼦⼥费', name: 'oneChild', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + Child + '</div>';
}
}
},jquery框架使用
{ display: '通讯费', name: 'communication', width: 90, totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Totalmunication + '</div>';
}
}
},
{ display: '交通费', name: 'transportation', width: 90 , totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + ansportation + '</div>';
}
}
},
{ display: '动态⼯资', name: 'dynamic', width: 90, totalSummary:
{
/
/type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.dynamic + '</div>';
}
}
},
{ display: '加班费', name: 'overTime', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.overTime + '</div>';
}
}
},
{ display: '其他⼯资', name: 'other', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + her + '</div>';
}
}
},
{ display: '应发⼯资合计', name: 'amount', width: 90 , totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.amount + '</div>';
}
}
},
{ display: '社保基数', name: 'socialBase', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.socialBase + '</div>';
}
}
},
{ display: '公积⾦基数', name: 'fundBase', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.fundBase + '</div>';
}
}
},
{ display: '医保基数', name: 'medicalBase', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + dicalBase + '</div>';
}
}
},
{ display: '养⽼保险', name: 'socialInsurance', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.socialInsurance + '</div>';
}
}
},
{ display: '失业保险', name: 'unemploymentInsurance', width: 90, totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.unemploymentInsurance + '</div>';
}
}
},
{ display: '医疗保险', name: 'medicalInsurance', width: 90 , totalSummary:
{
/
/type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + dicalInsurance + '</div>';
}
}
},
{ display: '午餐费', name: 'lunch', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.lunch + '</div>';
}
}
},
{ display: '住房公积⾦', name: 'fund', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.fund + '</div>';
}
}
},
{ display: '扣款合计', name: 'deduction', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.deduction + '</div>';
}
}
},
{ display: '个税专项扣除', name: 'taxFree', width: 90 , totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.taxFree + '</div>';
}
}
},
{ display: '应纳税所得额', name: 'taxBase', width: 90 , totalSummary:                                {
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.taxBase + '</div>';
}
}
},
{ display: '个⼈所得税', name: 'tax', width: 90, totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.tax + '</div>';
}
}
},
{ display: '实发⼯资1', name: 'salary1', width: 90 , totalSummary:
{
//type: 'count'
render: function (sum, column, cell)
{
test = cell;
return '<div>' + data1.Total.salary1 + '</div>';
}
}
},
{ display: '⼯会会费', name: 'dues', width: 90, totalSummary:
{

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。