ExtJs使用小結





自動匹配


<span style="font-size:18px;">/*
 * 自動匹配
 */
頁面調用:
	getautocomplete(ctx+'/ajaxAction.do?method=json&common=getUserinfo&classes=indicatorConfServiceImpl', 'username','name');
需要引入:
<script type="text/javascript" src="${ctx}/base/commons/scripts/jquery.autocomplete.js"></script>


function getautocomplete(url,autoid,type){
	$.getJSON(url, function(data){
		data = data.list;
		var parsed = [];
		for (var i = 0; i < data.length; i++) {
			parsed[parsed.length] = {
				name : data[i].name,
				to : data[i].to

			}
		}
		if(type!=0&&!type){//操作類型爲空說明獲取的是id否則爲
			$("#"+autoid).autocomplete(parsed, {
				//  max: 10,    //列表裏的條目數
				minChars : 0, //自動完成激活之前填入的最小字符
				//width : 160, //提示的寬度,溢出隱藏
				scrollHeight : 200, //提示的高度,溢出顯示滾動條
				scroll : true,
				matchContains : true, //包含匹配,就是data參數裏的數據,是否只要包含文本框裏的數據就顯示
				autoFill : false, //自動填充
				formatItem : function(row, i, max) {
					return row.name;
				},
				formatMatch : function(row, i, max) {
					return row.name;
				},
				formatResult : function(row) {
					return row.name;
				}
			}).result(function(event, row, formatted) {
				$("#"+autoid).val(row.to);
			});
		}else{
			var ids=autoid.split("#");
			var twoID=false;
			if(ids.length==2){
				twoID=true;
				autoid=ids[1];
			}
			$("#"+autoid).autocomplete(parsed, {
				//  max: 10,    //列表裏的條目數
				minChars : 0, //自動完成激活之前填入的最小字符
				//width : 160, //提示的寬度,溢出隱藏
				scrollHeight : 200, //提示的高度,溢出顯示滾動條
				scroll : true,
				matchContains : true, //包含匹配,就是data參數裏的數據,是否只要包含文本框裏的數據就顯示
				autoFill : false, //自動填充
				formatItem : function(row, i, max) {
					return    row.name + '(' + row.to + ')';
				},
				formatMatch : function(row, i, max) {
					 return row.name + row.to;
				},
				formatResult : function(row) {
					return row.name + '(' + row.to + ')';
				}
			}).result(function(event, row, formatted) {
				if(twoID){
					$("#"+ids[0]).val(row.to);
					$("#"+autoid).val(row.name);
				}else{
					$("#"+autoid).val(row.name);
				}
				
			});
		}
	});
	
}</span>



列顯示不全只顯示部分


<astyle="white-space:nowrap; text-overflow:ellipsis; overflow:hidden;width:380px;height: 25px;

line-height:25px;display:block;text-align:left;"title="${question.title}"  href="${ctx}/template/web/answer.jsp?questionid=${question.questionid}"target="_blank"></a>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章