ajax返回的数据 用easyui的datagrid的表格来循环显示,用灰色背景的是隐藏的列。点击可以获取到隐藏的值

 
 
$.post(basePath + "/tranSportOrderController/getcount.py", {
					traditional:true,
					ids: ids,
					orderId : orderId
				}, function(result) {
					if (result.success){
						 $('#countCar').datagrid('loadData', { total: 0, rows: [] }); 
						for (var machine=0;  machine<result.data.length;machine++) {
						   var data={
							    'orderId':result.data[machine].orderId,
							    'loadCarId':result.data[machine].loadCarId,
						            'orderCode':result.data[machine].orderCode,
							    'ordercarTypeName':result.data[machine].ordercarTypeName,
							    'orderTotalPrice':result.data[machine].orderTotalPrice,
							    'carLicenseNumber':result.data[machine].carLicenseNumber,
							    'carTypeName':result.data[machine].carTypeName,
							    'idlemotion':result.data[machine].idlemotion,
							    'motioncost':result.data[machine].motioncost,
							    'Idlemotionspend':result.data[machine].Idlemotionspend,
							    'motionspend':result.data[machine].motionspend,
							    'cost':result.data[machine].cost,
							    'profit':result.data[machine].profit,
							    'percent':result.data[machine].percent,
							    'userCode':result.data[machine].userCode}
						   $('#countCar').datagrid('appendRow', data);
						}
				    }
				}, 'json');


 
 
	 $('#countCar').datagrid({
			columns:[[ {field:'orderId',title:'订单号',align:'center',width:10, rowspan:2},
   				   {field:'loadCarId',title:'配载车辆号',align:'center',width:10, rowspan:2},
   			           {field:'carTemporaryId',title:'临时车辆号',align:'center',width:10, rowspan:2},
                                   <!--上面3个字段为隐藏字段-->
			           {field:'orderCode',title:'订单编码',align:'center',width:210, rowspan:2},    
			           {field:'ordercarTypeName',title:'类型',align:'center',width:120, rowspan:2},
			           {field:'orderTotalPrice',title:'价格(元)',align:'center',width:120, rowspan:2},
			           {title:'费用组成(距离 * 单价 + 里程 * 单价 = 成本',align:'center',colspan:4},
			           {field:'carLicenseNumber',title:'车牌号',align:'center',width:90, rowspan:2},
			           {field:'carTypeName',title:'车辆类型',align:'center',width:120,rowspan:2},
			           {field:'cost',title:'成本(元)',align:'center',width:110,rowspan:2},
			           {field:'profit',title:'毛利(元)',align:'center',width:130,rowspan:2}, 
			           {field:'percent',title:'毛利率(%)',align:'center',width:130,rowspan:2} 
			       ],[
				   {field:'idlemotion',title:'距离(千米)',align:'center',width:150},
				   {field:'Idlemotionspend',title:'价格总计(元)',align:'center',width:150},
			           {field:'motioncost',title:'里程距离(千米)',align:'center',width:150}, 
			           {field:'motionspend',title:'里程总计(元)',align:'center',width:150} 
			          ]]
		}); 
<table id="countCar" class="easyui-datagrid"data-options="rownumbers:true,singleSelect:true" title="表格" style="width: 100%;height:200px">
	<thead>
		<tr>
			<th data-options="field:'orderCode',width:210,align:'center'" rowspan="2">订单编码</th>
			<th data-options="field:'ordercarTypeName',width:120,align:'center'" rowspan="2">车辆类型(订单)</th>
			<th data-options="field:'orderTotalPrice',width:120,align:'center'" rowspan="2">订单价格(元)</th>
			<th colspan="4">费用组成(距离 * 单价 + 里程 * 单价 = 成本)</th>
			<th data-options="field:'carLicenseNumber',width:90,align:'center'" rowspan="2">车牌号</th>
			<th data-options="field:'carTypeName',width:120,align:'center'" rowspan="2">车辆类型</th>
			<th data-options="field:'cost',width:110,align:'center'" rowspan="2">成本(元)</th>
			<th data-options="field:'profit',width:130,align:'center'" rowspan="2">毛利(元)</th>
			<th data-options="field:'percent',width:130,align:'center'" rowspan="2">毛利率(%)</th>
		</tr>
		<tr>
			<th data-options="field:'idlemotion',width:150,align:'center'">空程距离(千米)</th>
			<th data-options="field:'Idlemotionspend',width:150,align:'center'">价格总计(元)</th>
			<th data-options="field:'motioncost',width:150,align:'center'">里程距离(千米)</th>
			<th data-options="field:'motionspend',width:150,align:'center'">里程总计(元)</th>
		</tr>
	</thead>
</table>


ajax返回的数据 用easyui的datagrid的表格来循环显示,用灰色背景的是隐藏的列。点击可以获取到隐藏的值,如有什么不妥之处还请提出意见谢谢。

参考的:http://bbs.csdn.net/topics/390970679



 
 
 

猜你喜欢

转载自blog.csdn.net/lx1309244704/article/details/53705233