extjs Combo远程数据问题
使用extjs combobox时遇到一些问题,点击下拉小三角后台打印json数据:
[{"id":1,"name":"车身科"},{"id":2,"name":"底盘科"},{"id":3,"name":"电器科"}]
但combobox中什么也没显示,不知道出错在什么地方,望各位大大指点迷津。
JS源码:
Ext.onReady(function() {
	Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
	Ext.QuickTips.init();
	
	var ds = new Ext.data.JsonStore({
		reader: new Ext.data.JsonReader({
			fields: ['id', 'name'],
			root: 'jsonStore'
		}),
		proxy: new Ext.data.HttpProxy({
			url: 'department_listCombo.action'
		})
		});
	//ds.load();
	var department = new Ext.FormPanel( {
		renderTo : userForm,
		frame : true,
		title : '用户表单',
		width : 250,
		autoHeight : true,
		layout : "form",
		hideLabels : false,
		buttonAlign : "center",
		labelAlign : "right",
		//labelWidth : 80,
		items : [ {
			xtype: 'combo',
			name:"nameCombo",
			store: ds,
			mode: 'remote',
			triggerAction : 'all',
			//forceSelection: true,
			readOnly : false,
			//editable:false,
			//pageSize:0,
			emptyText : "---请选择---", 
			fieldLabel: '所属部门',
			//valueField : 'id',
			displayField:'name',
			//hiddenName:"hiddenId",
			width: 130
		} ],
		buttons : [ {
			text : '提交',
			//formBind : true, // only enabled once the form is valid
			//disabled : true,
			handler : function() {
			//Ext.Msg.alert("message",department.getForm());
				var form = user.getForm();
				if (form.isValid()) {
					//Ext.Msg.alert("message",form.findField('department.name').getValue());
					form.submit( {
						waitMsg : '正在提交数据,请稍后...',
						url : 'json/user_add.action',
						method : 'POST',
						success : function(form, action) {
							if(action.result.success){
								
								window.location.href="user_grid";
							}
						},
						failure : function(form, action) {
							Ext.Msg.alert('Failed', "err:"+action.result.success);
							//alert('Failed');
						}
					});
				}
			}
		},{
			text : '重置',
			handler : function() {
				department.form.reset();
			}
			}]
	});
});
              
                  extjs
                  action
                  combo
              
------解决方案--------------------
我印象中像你这样写的话,正确的json格式应该是类似{'jsonStore':{[{"id":1,"name":"车身科"},{"id":2,"name":"底盘科"},{"id":3,"name":"电器科"}]
}},这样才能和前台的root: 'jsonStore'对应;
至于怎么看前台返回的json可以用火狐DEBUG