产品使用总结备注

Gird使用
1.	设置编辑状态的代码:
 $("#bdxz_rowed td select").bind("change.edit",function(){
     $(this).parent().addClass("dirty-cell");
     $(this).parent().parent().addClass("edited");
});
2.	Grid里面:
格式化日期:formatter: "date", formatoptions:{newformat: 'Y-m-d'}
formatter:'date',sorttype:'date',editrules:{date:true},search:false,editable:false,formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'},datefmt:'Y-m-d H:i:s
格式化那种是否的:formatter:getYesOrNoDesc
var yesOrNoArr = {"0":"否","N":"否","n":"否","NO":"否","no":"否","No":"否","1":"是","Y":"是","y":"是","YES":"是","yes":"是","Yes":"是"};
	function getYesOrNoDesc(code){
		return yesOrNoArr[code];
	}
3.	如果用bizdirt返回的JSON数据是类似于这样的,取值例子:
JSON返回的值:[{"uuid":"8a4d83543e4432f2013e4432f2420000"}]
data[0].uuid; 或 data[0]["uuid"];

4.	日期的处理:
显示:
<input id="prepareDate" name="prepareDate" type="text" class="Wdate" value=""/>
JS:
new biz.datepicker({id:"#prepareDate",dateFmt:"yyyy-MM-dd"});
需要回显:
<input id="prepareDate" name="prepareDate" value="<fmt:formatDate value="${busScalefarmInfo.prepareDate}" type="date" dateStyle="default"/>" type="text" class="Wdate" style="width:120px;"/>
如果格式不规则回显用:
今天是:<fmt:formatDate value="${now}" pattern="G yyyy年MM月dd日 E"/><br>
现在是:<fmt:formatDate value="${now}" pattern="a HH:mm:ss.S z"/>
结果:
今天是:公元 2007年10月19日 星期五
现在是:下午 20:04:11.484 CST
<input id="samplingTime" name="samplingTime" type="text" class="Wdate" value="<fmt:formatDate value="${busSamplingRecordN.samplingTime}" type="date" pattern="yyyy-MM-dd HH"/>"/>
				
5.	下拉框的处理:
页面片段:<select id="fieldPositionRelId" name="fieldPositionRelId" class="select" ></select>
JS片段:
new biz.select({id:"#fieldPositionRelId",value:"<c:out value='${busMonitorWellInfoN.fieldPositionRelId}'/>",url:"<c:url value='/bizdirt/getFieldPositionRelId' />",choose: true,
	ajaxOptions:{
		complete: function(){
		    /*编辑的时候,4.1,4.2和12根据 4.1的结果进行相关显示或隐藏*/
		    if($("#fieldPositionRelId").find("option:selected").attr("code") == '101901'){//场地内,设置 场地方位和场地数据不可编辑;12.与地下水水流方位关系为不可编辑
				$("#fieldPositionCode").attr("value",'');
				$("#fieldPositionCode").attr("disabled",true);
				$("#fieldDistance").attr("value",'');
				$("#fieldDistance").attr("disabled",true);
				$("#flowPositionRelId").attr("value",'');
				$("#flowPositionRelId").attr("disabled",true);
		    }
		    else{//场地外和 请选择
		    	$("#fieldPositionCode").attr("disabled",false);
				$("#fieldDistance").attr("disabled",false)
				$("#flowPositionRelId").attr("disabled",false);

				new biz.validate({id:"#fieldPositionCode",required: function(){return !(saveDraft)}});
				new biz.validate({id:"#fieldDistance",required: function(){return !(saveDraft)},decimal:[10,1]});
		    }
		    /*-------------end-------------*/
		 }
	}
dirt.xml里面的片段:
<!-- 地下水监测井与场地方位关系代码 select option -->
	<dirt id="getFieldPositionRelId" cache="true" expiration="-1">
		<sql>select uuid as value, code, full_name as name from tb_cod_field_desc where table_code_flag = '10000024'</sql>
	</dirt>

6.	Grid中某个name的值通过id异步获取显示:
Gird: 
{name : "typeIdName",label:"类型",formatter: dealTypeIdName},
{name : "typeId",hidden:true,label:"类型ID"},
Function:
function dealTypeIdName(cellvalue, options, rowobject){
	var rtn = '';
    var typeId = rowobject.typeId;
	$.ajax({
	    url: "<c:url value='/bizdirt/getCodeNameById'/>?uuid="+typeId,
	    async:false,//这个是关键,必须有
		success: function(data, textStatus, jqXHR){
			rtn = data[0].full_name;//页面获取json中的数据方法
		},
		error: function(){}
	});
	return rtn;
}
dirt.xml字典:
<!-- 根据 uuid 获取 code name -->
	<dirt id="getCodeNameById" cache="false" expiration="-1">
		<sql>select full_name from TB_COD_FIELD_DESC where uuid =:uuid </sql>
	</dirt>

7.	后台给grid获取分页数据:
StringBuffer sql = new StringBuffer();
List params = new ArrayList();
	sql.append("select t.* from tb_bus_sensitive_point_n t where t.data_state = 1 ");
	if(busSensitivePointN.getProjectBaseInfoId() != null){
	  sql.append("and t.project_base_info_id = :project_base_info_id ");
	  params.add(busSensitivePointN.getProjectBaseInfoId());
	}
//		page = dao.createQuery(sql.toString(), params).fetch(page);//这个出来的是大写,数据库是什么就是什么
	page = dao.createQuery(busSensitivePointN.getClass(), sql.toString(), params).fetch(page);//加上类之后,就会根据属性变化
8.	下拉框select: 
$("#sel").attr("value",'-sel3');//设置value=-sel3的项目为当前选中项
9.	Comboboxtree的回显:
var typeTreeNode = typeTreeObj.getNodeByParam("uuid", ret.typeId);
typeTreeObj.selectNode(typeTreeNode);
10.	

 

你可能感兴趣的:(总结)