grid 的定义: 代码如下: ds = new Ext.data.Store({ baseparams : { start : 0, limit : RowCount }, proxy : new Ext.data.HttpProxy({ url :'test2.do' }), reader : new Ext.data.JsonReader({ root : 'data', totalProperty : 'totalCount' }, [{ name : "bh" }, { name : "test" }]); }); var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), { header : "编号", dataIndex : "bh" }, { header : "测试", dataIndex : "test", renderer : renderer, editor : comboBox }]); grid = new Ext.grid.EditorGridPanel({ title : '测试', ds : ds, cm : cm, clicksToEdit : 1, viewConfig : { forceFit : true }, bbar : new Ext.PagingToolbar({ pageSize : RowCount, store : ds, displayInfo : true, displayMsg : '显示第 {0} 条到 {1} 条记录,一共 {2} 条', emptyMsg : "没有记录" }) });
cm 的renderer函数 此方法为解决combobox修改后显示为id 代码如下: function renderer(value, p, r) { var index = comboDS.find(Ext.getCmp('cb').valueField, value); var record = comboDS.getAt(index); var displayText = ""; if (record == null) { displayText = value; } else { displayText = record.data.display;// 获取record中的数据集中的display字段的值 }