Hey man I forked your fiddle and made some change that I think solve your problem:
https://fiddle.sencha.com/#view/editor&fiddle/27ua
Basically I added a viewConfig
to the grid with a cellclick
event listener. The cellclick
event fires first; in the event handler we check the value of the cellIndex
parameter in order to determine which grid column was clicked to fire the event. We then set the value of our flag variable to the cellIndex
value, so we can access that value in the beforedeselect
event handler of the selection model. Finally we return false from the beforedeselect
if the value of the flag is anything other than 0.
Here's the code:
var store = Ext.create('Ext.data.Store', {
fields: ['name', 'email', 'region'],
data: [{
name: 'xyz',
email: '[email protected]',
region: 'Arizona'
}, {
name: 'xyz',
email: '[email protected]',
region: 'Alaska'
}, {
name: 'xyz',
email: '[email protected]',
region: 'Alaska'
}, {
name: 'xyz',
email: '[email protected]',
region: 'Alabama'
}]
});
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data: [{
"abbr": "AL",
"name": "Alabama"
}, {
"abbr": "AK",
"name": "Alaska"
}, {
"abbr": "AZ",
"name": "Arizona"
}]
});
var targetedCell = -1;
Ext.create('Ext.grid.Panel', {
id: 'theGrid',
viewConfig: {
listeners: {
cellclick: function(view, cell, cellIdx, record, row, rowIdx, eOpts) {
targetedCell = cellIdx;
}
}
},
title: 'data',
store: store,
width: 400,
renderTo: Ext.getBody(),
selModel: new Ext.selection.CheckboxModel({
checkOnly: true,
listeners: {
beforedeselect: function (thisSelModel, record, idx, eOpts) {
if(targetedCell != 0) {
return false;
}
return true;
}
}
}),
columns: [{
text: 'Name',
dataIndex: 'name',
}, {
text: 'Email',
dataIndex: 'email',
flex: 1,
}, {
text: 'State',
dataIndex: 'region',
editor: {
xtype: 'combo',
store: states,
displayField: 'name',
valueField: 'name',
listeners: {}
}
}],
plugins: {
ptype: 'cellediting',
clicksToEdit: 1
}
});