Extjs 4.0 ComboBox JSON

在Extjs中,ComboBox在JSON解析和使用中,如果有一点问题就会出错。在网上找了好多方法,多不对。最后发现一个老外的解决方案。

var remoteStore = new Ext.data.JsonStore({
	autoLoad : true,

	fields : ['name', 'id'],
	// data: [['开发部', 1], ['行政部', 2], ['销售部', 3], ['质检部', 4], ['售后部', 5]]
//	proxy : new Ext.data.HttpProxy({
//		url : 'ims/autocomplete'
//	}),
	proxy: {
        type: 'ajax',
        url: 'ims/autocomplete',
        reader: {
            type:'json',
            root: 'rows'
        }
    },
	root : 'rows',
//	url : 'ims/autocomplete'
});

remoteStore.load();
var autoCom = new Ext.form.ComboBox({

	labelAlign : 'right',
	fieldLabel : '姓名',
	labelWidth : 60,
	name : 'szname',
	x : 0,
	y : 10,
	width : 210,
//	mode : 'remote',
	 mode:'local',
	queryParam : 'search',
	displayField : 'name',
//	valueField : 'id',
	typeAhead : true,
	triggerAction : 'all',
	selectOnFocus : true,
	store : remoteStore,
	minChars : 1
});

我的JSON格式为:转载注明出处(http://blog.csdn.net/fuli_mouren/article/details/9049915

String json = "{rows:" +
				"[{'name':'李四','id':'java'}," +
				"{'name':'jinglong','id':'extjs'}]" +
				"}";



posted @ 2013-06-07 17:53  梅尔加德斯  阅读(168)  评论(0编辑  收藏  举报