0
我hv一個editorGridPanel和它的selmodel = new Ext.grid.CheckboxSelectionModel(),但我想通過使用getSelectedCell獲取選定的列,是否有可能?extjs getselectedcell()但沒有使用Ext.grid.CellSelectionModel
我hv一個editorGridPanel和它的selmodel = new Ext.grid.CheckboxSelectionModel(),但我想通過使用getSelectedCell獲取選定的列,是否有可能?extjs getselectedcell()但沒有使用Ext.grid.CellSelectionModel
這裏是工作示例:http://jsfiddle.net/qxpfJ/1/
function cellRenderer(value, column, record, row, col){
return Ext.String.format('<span key="{0}_{1}_{2}_{3}">{4}</span>',
record.data.id, column.column.dataIndex, row, col, value);
}
Ext.create('Ext.grid.Panel', {
title: 'Countries',
selType : 'cellmodel',
renderTo: Ext.getBody(),
store: Ext.create('Ext.data.Store', {
fields:['id', 'cName'],
data:{'items':[ { id: 1, cName: 'Australia' },
{ id: 2, cName:'Germany' },
{ id: 3, cName:'Russia' },
{ id: 4, cName:'United States' }]},
proxy: {
type: 'memory',
reader: { type: 'json', root: 'items' }
}
}),
columns: [{ text: 'id', dataIndex: 'id', renderer: cellRenderer },
{ text: 'Country', dataIndex: 'cName', flex: 1, renderer: cellRenderer }],
listeners:{
selectionchange: function(me, selected, eOpts){
var sel = Ext.query('.x-grid-cell-selected span');
if(sel[0]){
var data = sel[0].getAttribute('key').split('_');
container.update(Ext.String.format(
'id={0};<br/>column="{1}";<br/>rowIndex={2};<br/>colIndex={3};',
data[0], data[1], data[2], data[3]));
}
}
}
});
var container = Ext.create('Ext.container.Container', {
renderTo: Ext.getBody()
});
編輯
這裏是相同的樣品,但對於checkboxmodel:http://jsfiddle.net/qxpfJ/2/
Ext.create('Ext.grid.Panel', {
title: 'Countries',
selType : 'checkboxmodel',
renderTo: Ext.getBody(),
store: Ext.create('Ext.data.Store', {
fields:['id', 'cName'],
data:{'items':[ { id: 1, cName: 'Australia' },
{ id: 2, cName:'Germany' },
{ id: 3, cName:'Russia' },
{ id: 4, cName:'United States' }]},
proxy: {
type: 'memory',
reader: { type: 'json', root: 'items' }
}
}),
columns: [{ text: 'id', dataIndex: 'id' },
{ text: 'Country', dataIndex: 'cName', flex: 1 }],
listeners:{
cellclick: function(me, td, cellIndex, record, tr, rowIndex, e, eOpts){
container.update(Ext.String.format(
'id={0};<br/>rowIndex={1};<br/>cellIndex={2};',
record.data.id, rowIndex, cellIndex));
}
}
});
var container = Ext.create('Ext.container.Container', {
renderTo: Ext.getBody()
});
但我的seltype必須是'checkboxmodel' – newstartgirls
我改變了我的答案 –