cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
beforeedit: function(obj) {
return obj.record.get('status');
//you can update the above logic to something else
//based on your criteria send false to stop editing
}
}
});
beforeedit( Object e, Object eOpts )
Fires before cell editing is triggered. Return false from event handler to stop the editing.
Parameters
- e : Object
- An edit event with the following properties:
- grid - The grid
- record - The record being edited
- field - The field name being edited
- value - The value for the field being edited.
- row - The grid table row
- column - The grid Column defining the column that is being edited.
- rowIdx - The row index that is being edited
- colIdx - The column index that is being edited
- cancel - Set this to true to cancel the edit or return false from your handler.
- eOpts : Object
- The options object passed to Ext.util.Observable.addListener.
Tip: You can use the same logic for Ext.grid.plugin.RowEditing
In case you would like to ask the user whether they would like to edit the grid cell. Here is a sample code to do just that using a variable that is switched on or off based on the users choice.
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
'beforeedit': function(e) {
var me = this;
var allowed = !!me.isEditAllowed;
if (!me.isEditAllowed)
Ext.Msg.confirm('confirm', 'Are you sure you want edit?', function(btn){
if (btn !== 'yes')
return;
me.isEditAllowed = true;
me.startEditByPosition({row: e.rowIdx, column: e.colIdx});
});
return allowed;
},
'edit': function(e) {
this.isEditAllowed = false;
}
}
})
],
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.