var typeStore=new Ext.data.SimpleStore({ fields : ["id", "name"], data : [[‘1‘, ‘电话‘],[‘2‘,‘QQ‘],[‘3‘,‘邮件‘],[‘4‘,‘地址‘]] });
先自定义一个store或者读取某些数据,再在ColumnModel中定义某行数据
{header:‘联系方式‘,dataIndex:‘type‘,renderer:getStockType,editor:new Ext.form.ComboBox({store:typeStore, valueField :"id",displayField: "name",mode: ‘local‘,forceSelection: true,hiddenName:‘id‘, editable: false,triggerAction: ‘all‘}) },
接着定义显示的值转换问题:
function getStockType(value) { var rowIndex = typeStore.find("id",""+value); if(rowIndex<0) return ‘请选择..‘; var record=typeStore.getAt(rowIndex); return record ? record.get(‘name‘) : ‘请选择..‘; }
注意使用EditorGridPanel。