BootstrapTable获取表数据

/**
 * 初始化SUM表数据
 */
function putDataToStatisticDataTable() {
	$("#statisticDataTable").bootstrapTable('getData').splice(0);	//清空表数据
	var materialchangeitemArr = $("#table-materialchangeitem").bootstrapTable('getData');
	var sumAffectHarnessPartNo,sumCost,sumWeight;
	var tempStr = "";	//此变量用于判断affectHarnessPartNo是否已经统计
	for (var x = 0; x < materialchangeitemArr.length; x++) {
		if (tempStr.indexOf("###"+materialchangeitemArr[x].affectHarnessPartNo+"%%%") >= 0) continue;
		sumAffectHarnessPartNo = materialchangeitemArr[x].affectHarnessPartNo;
		sumCost = 0,sumWeight = 0;
		for (var y = x; y < materialchangeitemArr.length; y++) {
			if (materialchangeitemArr[y].affectHarnessPartNo==sumAffectHarnessPartNo) {
				if (materialchangeitemArr[y].action=="Add") {
					sumCost += materialchangeitemArr[y].costFromLibrary*materialchangeitemArr[y].changeQuantity;
					sumWeight += materialchangeitemArr[y].weight*materialchangeitemArr[y].changeQuantity;
				} else if(materialchangeitemArr[y].action=="Delete"){
					sumCost -= materialchangeitemArr[y].costFromLibrary*materialchangeitemArr[y].changeQuantity;
					sumWeight -= materialchangeitemArr[y].weight*materialchangeitemArr[y].changeQuantity;
				} else {
					sumCost += materialchangeitemArr[y].smallCost*materialchangeitemArr[y].changeQuantity;
					sumWeight += materialchangeitemArr[y].smallWeight*materialchangeitemArr[y].changeQuantity;
				}
			}
		}
		var row={
				sumAffectHarnessPartNo: sumAffectHarnessPartNo,
				sumCost: Math.round(sumCost*1000)/1000,
				sumWeight: Math.round(sumWeight*1000)/1000
		};
		$('#statisticDataTable').bootstrapTable('append', row);
		tempStr = tempStr+"###"+materialchangeitemArr[x].affectHarnessPartNo+"%%%";
	}
	$('#statisticDataTable').bootstrapTable('refreshOptions',{sidePagination:"client"});
}

你可能感兴趣的:(BootstrapTable获取表数据)