日期:2014-05-16 浏览次数:20630 次

<table class="display" id="customerInfo">
	<thead>
		<tr>
			<th>ID</th>
            略
			<th>身高</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="8"></td> 
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<th>ID</th>
            略
			<th>身高</th>
		</tr>
	</tfoot>
</table>$('#customerInfo').dataTable();
function retrieveData( sSource, aoData, fnCallback ) {
    //将客户名称加入参数数组
	aoData.push( { "name": "customerName", "value": $("#customerName").val() } );
	$.ajax( {
		"type": "POST", 
		"contentType": "application/json",
		"url": sSource, 
		"dataType": "json",
		"data": JSON.stringify(aoData), //以json格式传递
		"success": function(resp) {
			fnCallback(resp.returnObject); //服务器端返回的对象的returnObject部分是要求的格式
		}
	});
}
var oTable = null;
$(function() {
	$("#customerInfo").hide();
} );
//“检索”按钮的处理函数
function search() {
	if (oTable == null) { //仅第一次检索时初始化Datatable
		$("#customerInfo").show();
		oTable = $('#customerInfo').dataTable( {
			"bAutoWidth": false,					//不自动计算列宽度
			"aoColumns": [							//设定各列宽度
							{"sWidth": "15px"},
							{"sWidth": "80px"},
							{"sWidth": "160px"},
							{"sWidth": "110px"},
							{"sWidth": "120px"},
							{"sWidth": "140px"},
							{"sWidth": "140px"},
							{"sWidth": "*"}
						],
			"bProcessing": true,					//加载数据时显示正在加载信息
			"bServerSide": true,					//指定从服务器端获取数据
			"bFilter": false,						//不使用过滤功能
			"bLengthChange": false,					//用户不可改变每页显示数量
			"iDisplayLength": 8,					//每页显示8条数据
			"sAjaxSource": "customerInfo/search.do",//获取数据的url
			"fnServerData": retrieveData,			//获取数据的处理函数
			"sPaginationType": "full_numbers",		//翻页界面类型
			"oLanguage": {							//汉化
				"sLengthMenu": "每页显示 _MENU_ 条记录",
				"sZeroRecords": "没有检索到数据",
				"sInfo": "当前数据为从第 _START_ 到第 _END_ 条数据;总共有 _TOTAL_ 条记录",
				"sInfoEmtpy": "没有数据",
				"sProcessing": "正在加载数据...",
				"oPaginate": {
					"sFirst": "首页",
					"sPrevious": "前页",
					"sNext": "后页",
					"sLast": "尾页"
				}
			}
		});
	}
	//刷新Datatable,会自动激发retrieveData
	oTable.fnDraw();
}
public class JSONParam {
	private String name;
	private String value;
	
	//略
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
@ResponseBody
public JSONResponse sea