1. 程式人生 > >jquery 的mmgrid 載入資料時的傳引數的方式

jquery 的mmgrid 載入資料時的傳引數的方式

1:第一種方式

tbExpress = $('#tb-Express').mmGrid({
				height: 365,
				cols: custCols,
				url: '${ctx}/customerManage/queryExpressInfomation?orgId='+organizeId,
				method: 'post',
				remoteSort: true,
				sortName: 'id',
				sortStatus: 'desc',
				multiSelect: false,
				params:function(){
					
					var qAddresseePhone = $("#qAddresseePhone").val();
					var qAddresseeName = $("#qAddresseeName").val();
					var qExpressNo = $("#qExpressNo").val();
					var expressName = $("#qexpressNameId").val();
					var expressState = $("#qexpressStateId").val();
					
					data = {"": ""};
					if (typeof(qAddresseePhone) != "undefined" && qAddresseePhone != ""){
						$(data).attr({"qAddresseePhone": qAddresseePhone});
					}
					if (qAddresseeName != ""){
						$(data).attr({"qAddresseeName": qAddresseeName});
					}
					if (qExpressNo != ""){
						$(data).attr({"qExpressNo": qExpressNo});
					}
					if (expressName != ""){
						$(data).attr({"expressName": expressName});
					}
					if (expressState != ""){
						$(data).attr({"expressState": expressState});
					}
					return data;
		        },
				checkCol: false,
				fullWidthRows: false,
				autoLoad: false,
				showBackboard: false,
				plugins:[$('#pg').mmPaginator({"limitList":[10]})]
			});

第二種方式:
	tbFreeVehicleDetail = $('#tb_freeVehicleDetail').mmGrid({
		height:365,
		cols:cols,
		url:'${ctx}/reportExt/findFreeVehicleDetail',
		method:'get',
		params:function(){
			var projectId = $('#projectId').val();
			var companyName = $('#companyName').val();
			var getOutDate = $('#outDate').val();
			var getOutEndDate = $('#outEndDate').val();
			var licensePlate = $('#licensePlate').val();
			var freeType = $('#freeType').val();
			var operatorName = $('#operatorName').val();
			var data = {"projectId":projectId,"operatorName":operatorName.trim(),"licensePlate":licensePlate.trim(),"freeType":freeType,"companyName":companyName};
			if(getOutDate.length != 0){
				$(data).attr({"getOutDate": getOutDate});
			}
			if(getOutEndDate.length != 0){
				$(data).attr({"getOutEndDate": getOutEndDate});
			}
			return data;
		},
		remoteSort:true,
		sortName:'id',
		sortStatus:'desc',
		multiSelect:false,
		checkCol:false,
	    nowrap:true,
		fullWidthRows:false,
		autoLoad:false,
		showBackboard:false,
		plugins:[pg]
	});

第三種方式:先獲取form表單
tbfixedUserVehicleInfo = $('#tb_fixedUserVehicleStatistics').mmGrid({
			height:365,
			cols:cols,
			url:'${ctx}/reportExt/getfixedUserVehicleStatistics?orgId='+organizeId,
			method:'post',
			params:function(){
				var selectForm = getFormData("select-form");
				selectForm.custName = selectForm.custName.trim();
				selectForm.companyName = selectForm.companyName.trim();
				selectForm.vehicleLicense = selectForm.vehicleLicense.trim();
				selectForm.expireDate = selectForm.expireDate.trim();
				selectForm.expireDayNum = selectForm.expireDayNum.trim();
				var chargeTypeId = $("#chargeTypeId").val();
				if(chargeTypeId == "-1"){
					chargeTypeId = "";
					selectForm["chargeTypeId"]=chargeTypeId;
				}
				return selectForm;
			},
			remoteSort:true,
			sortName:'id',
			sortStatus:'desc',
			multiSelect:false,
			checkCol:true,
			fullWidthRows:false,
			autoLoad:false,
			plugins:[pg]
		});