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

extjs2.x中带有拼音检索功能combo

1、extjs2.2版本

2、js代码示例

?

?

//Combobox, IE and hideTrigger:true bug 
Ext.form.TriggerField.override({
    afterRender: function() {
         Ext.form.TriggerField.superclass.afterRender.call(this);
    }
});

?

{
	xtype:'combo',
	fieldLabel: '客户(拼音搜索)',
	labelSeparator: ':' + '&nbsp;&nbsp;<img src="'+ Ext.NEEDED_IMAGE_URL + '"/>',
	hiddenName:'ownerId',
	valueField:'id',
	displayField:'name',
	autoLoad : false, 
	width:165,
	loadingText : '查询中...', 
	maxHeight:200,
	pageSize:10,
	mode:'remote',
	store:new Ext.data.JsonStore({
		storeId:'pigOwnerStore',
		url: 'data/pagingOwner.do',
		root: 'owners',
		totalProperty: 'totalCount',
		remoteSort: true,
		fields: ['id','name']
	}),
	typeAhead : true,
	minChars:2,
	hideTrigger : true,
	forceSelection : false,
	queryParam: 'searchString',
	listeners : {
		select : function(combo, record, index) {
			Ext.getCmp('owner_quid').setValue(combo.getRawValue());
		},
		'blur' : function(f) {
				var textvalue = this.el.dom.value; 
				Ext.getCmp('owner_quid').setValue(textvalue);
		}
	},
	allowBlank : false,
	blankText    :'请选择宰户',
	msgTarget :'side'
}

?

3、action控制器

?

/**
	 * 带有检索功能的客户选择
	 * @param orgNo
	 * @param query
	 * @param model
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("/data/pagingOwner.do")
	public String getPagingOwners(String searchString,Model model,Integer start,Integer limit){
		System.out.println(">>>searchString:" + searchString);
		Paging paging = dataManager.getSpellClients(searchString,0,start, limit);
		String json = "{totalCount:" + paging.getTotalCount() + ",Owners:"
				+ JSONArray.fromObject(paging.getCollections(), JsonUtils.registerDateProcessor(new JsonConfig()))
				+ "}";
		return JsonUtils.returnJsonModelAndView(model, json);
	}

??