ExtJs EditorGridPanel中加入 ComboBox
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../extjs-2.0/resources/css/ext-all.css">
<title>Ext 2.0 Editor Grid Example</title>
<script type="text/javascript" src="../extjs-2.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../extjs-2.0/ext-all-debug.js"></script>
<script type="text/javascript">
<span id="more-800"></span>
Ext.onReady(function(){
var gridData = [
[1, 'US', 'Washington', 9826630]
,[2, 'UK', 'London', 244820]
,[3, 'DE', 'Berlin', 357021]
,[4, 'F', 'Paris', 674843]
,[5, 'NL', 'Amsterdam', 41526]
,[6, 'SK', 'Bratislava', 49035]
,[7, 'JP', 'Tokyo', 377873]
,[8, 'A', 'Vienna', 88872]
,[9, 'CA', 'Ottawa', 9984670]
];
var countries = [
['US', 'United States']
,['UK', 'United Kingdom']
,['DE', 'Germany']
,['F', 'France']
,['NL', 'Netherlands']
,['SK', 'Slovakia']
,['JP', 'Japan']
,['A', 'Austria']
,['CA', 'Canada']
];
var combo = new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
fields:['countryCode', 'countryName']
,data:countries
,id:0
})
,valueField:'countryCode'
,displayField:'countryName'
,lazyRender:true
,triggerAction:'all'
,mode:'local'
});
var renderCountry = function(val, cell, record, rowIndex, colIndex, store) {
return this.getById(val).get('countryName');
}
var grid = new Ext.grid.EditorGridPanel({
store:new Ext.data.SimpleStore({
fields:['ID', 'countryCode', 'capital', 'area']
,data:gridData
,id:0
})
,columns:[{
header:'Country'
,sortable:true
,dataIndex:'countryCode'
,editor:combo
,renderer:renderCountry.createDelegate(combo.store)
},{
header:'Capital'
,sortable:true
,dataIndex:'capital'
,editor:new Ext.form.TextField({})
},{
header:'Area [km2]'
,sortable:true
,dataIndex:'area'
,align:'right'
,editor:new Ext.form.NumberField({})
}]
,viewConfig:{forceFit:true}
});
var win = new Ext.Window({
title:'Ext 2.0 Editor Grid Example'
,layout:'fit'
,width:400
,height:300
,items:[grid]
});
win.show();
});
</script>
</head>
<body>
</body>
</html>来自:http://extjs.net/forum/showthread.php?p=94773
var renderCountry = function(val, cell, record, rowIndex, colIndex, store) {
return this.getById(val).get(‘countryName’);
}
我遇到 对象不支持此属性或方法 这样的错误是什么原因?