Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  168] [ 7]  / answers: 1 / hits: 29908  / 13 Years ago, tue, august 2, 2011, 12:00:00

I am now building a web application with Ext-JS 4.0.2, and I am using a editable grid to control the data to be shown for a table on the same page.



To make the grid editable, I followed the API documentation and used the following:



selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2
})
]


However, for this grid, there are several cells that are not supposed to be changed.



I could simply let the event handler change the data back to the right state once it is changed in the grid, but this seems to be hacky, hard to maintain, and unreadable. Is there any better way to do this? I read the API but cannot find any useful attributes.



UPDATE



As for this particular app, just disable the first row would work. But I am also interested in choose several grid and make them not editable (imagine a Sudoku game with a grid).


More From » extjs

 Answers
27

As I've understand from comments you want to make first row not editable. There is ugly but quick solution. Assign to your plugin beforeedit handler. And when event is being fired check what row is being edited. If first - return false:



plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2,
listeners: {
beforeedit: function(e, editor){
if (e.rowIdx == 0)
return false;
}
}
})
]


Check out docs for beforeedit.



UPDATE



Docs say that beforeedit has such set of params:



beforeedit( Ext.grid.plugin.Editing editor, Object e, Object options )


But there is mistake. The correct sequance is:



beforeedit( Object e, Ext.grid.plugin.Editing editor, Object options )


I've updated example due to this fact.


[#90863] Monday, August 1, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joanneamiyaa

Total Points: 532
Total Questions: 127
Total Answers: 98

Location: Guam
Member since Tue, Nov 3, 2020
4 Years ago
;