因为Extjs 的Ext.grid.EditorGridPanel默认是行选择,所以如果你点击一个CELL再用这个方法是会报错的,解决方法是在grid定义时加上
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
就可以用grid.getSelectionModel().getSelected这个方法了,具体代码如下:
var grid = new Ext.grid.EditorGridPanel({
id: ‘stylegrid’,
wdith:290,
height:290,
store : gridstore,
sm: new Ext.grid.RowSelectionModel({
singleSelect: true
}),
columns: [
{
header: 'apBasicId',
dataIndex: 'apBasicId',
hidden: true,
},{
header:'款号',
width: 100,
sortable: true,
dataIndex: 'style',
},{
header:'款号名字',
width: 100,
sortable: true,
dataIndex: 'stylename',
}]
});