PDA

View Full Version : CellEditing plugin requires an editor for the cell to be considered editable



jclark42796
30 Apr 2012, 10:46 AM
Upgrading from 4.0.7 to 4.1.0. We're using the Ext.grid.plugin.CellEditing plugin. The following code will display an alert when a cell is double clicked, but will not in 4.1.0. We don't have an 'editor' for the cell. We want a popup window to display. Without an editor 4.1.0 is saying the cell isn't editable (isCellEditable is checking for editors) and therefore, beforeedit is not fired . If I add an empty editor, i.e. {}, the default in-cell editor is used. I don't want this.

How do I get the behavior I had in 4.0.7?

Thanks,
Jim


Ext.define('Ext.simponspanel', {
alias: 'widget.simpsonspanel',
extend: 'Ext.grid.Panel',
//store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ header: 'Name', dataIndex: 'name', flex: 1},
{ dataIndex: 'title', hidden: true}
],
height: 200,
width: 400,
selModel: Ext.create('Ext.selection.CellModel'),

initComponent: function(config){

this.features = Ext.create('Ext.grid.feature.GroupingSummary', {
groupHeaderTpl: '{name}'
});

var clickHandler = function(e,opts){
alert('clicked');
};

this.store = new Ext.data.JsonStore({
fields: [{name: 'name'},{name: 'title'}],
isSortable: false,
groupField: 'title'
});

this.plugins = [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2,
listeners:{
beforeedit: clickHandler
}
})
];

this.store.add({title: 'math', name: 'D'}, {title: 'english', name: 'C'}, {title: 'english', name: 'B'}, {title: 'all', name: 'A'});
this.callParent();
}
});


Ext.application({
name: 'HelloExt',
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [
{ xtype: 'simpsonspanel'}
]
});
}
});

scottmartin
30 Apr 2012, 1:05 PM
Use this instead:



this.getSelectionModel().on('select', function(selModel, model, idx) {
alert('clicked');
}, this);



Scott.

jclark42796
30 Apr 2012, 1:34 PM
Thanks for the suggestion. I think this may have been the route I originally pursued when first looking for a solution. However, it doesn't appear as if the 'dblclick' event is supported.

Secondly, I also need a reference to the current column. I tried selModel.getCurrentPosition(), but undefined was returned.

Thanks,
Jim

scottmartin
30 Apr 2012, 2:04 PM
Try this for dblclick:



grid.getView().on('itemdblclick', function(view, record, item, index, node, e) {
//
}, this);


Have a look at the function parameters in the function above (in post 2)

Regards,
Scott.

jclark42796
1 May 2012, 5:47 AM
grid.getView().on('itemdblclick', function(view, record, item, index, node, e) { // }, this);


Ok, this works, but I still need a reference to the column of the current selection (in which the cell editor provided). How do I get a reference to the current column?

I have what looks like a "protected" spreadsheet. Some columns are editable and some are not. I have decorated the column definitions w/ metadata and need to inspect this metadata in the dblclick handler. It was not obvious to me how to do that with the params that are passed to the handler.

Thanks,
Jim

scottmartin
1 May 2012, 9:10 AM
Try the following:



var mypos = grid.getSelectionModel().getCurrentPosition();
console.log(mypos);


Scott.

jclark42796
1 May 2012, 10:23 AM
Ok, that did the trick, "columnHeader" gives me my column metadata. Thanks for your help.

Jim