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

<table width="95%"> <tr> <td> <table> <tr> <td> <form id="frmSearchCustomer"> <table> <tr> <td> 名称:<input type="text" name="name" /> アドレス:<input type="text" name="addr" /> </td> </tr> <tr> <td> 担当者:<input type="text" name="dandang" /> </td> </tr> </table> </form> </td> </tr> <tr> <td> <button id="search">检索</button> <button id="clear">清除条件</button> </td> </tr> </table> </td> </tr> <tr> <td> <table id="list"></table> <div id="pager"></div> </td> </tr> </table>
	$("#list").jqGrid({
		datatype : function(postdata) {
			postdata = mergeObject(jsonCondition, postdata);
			
			jQuery.ajax({
				type : 'POST',
				contentType : 'application/json',
				url : ROOT_PATH + '/customer/search.do',
				data : JSON.stringify(postdata),
				dataType : 'json',
				success : function(resp) {
					if (resp.successed) {
						var thegrid = jQuery("#list")[0];
						thegrid.addJSONData(resp.returnObject);
					} else {
						alert(resp.errors[0].message);
					}
				},
				error : ajaxFailed
			});
		},
		height : '100%',
		rowNum : '10',
		jsonReader : {
			repeatitems: false
		},
		colNames : ['顧客番号', '名称', 'アドレス', '担当者', '携帯', '電話①', '電話②'],
		colModel : [ 
				   {name:'id', index:'id', width:80}, 
				   {name:'name', index:'name', width:256},
				   {name:'addr', index:'addr', width:256},
				   {name:'dandang', index:'dandang', width:64},
				   {name:'mobile', index:'mobile', width:128},
				   {name:'phone1', index:'phone1', width:128},
				   {name:'phone2', index:'phone2', width:128},
				 ],
		pager : '#pager'
	});	var jsonCondition = {};
	
	function search() {
		jsonCondition = array2Json(jQuery("#frmSearchCustomer").serializeArray());
		jQuery("#list").trigger("reloadGrid");
	}	function mergeObject(src, dest) {
		var i;
		for(i in src) {
			dest[i]=src[i];
		}
		return dest;
	}	public class JQGridRequest