PDA

View Full Version : [Grid] disable a row issue in Chrome



foronoob
19 Jan 2009, 4:15 AM
Hi guys,
I have a problem with Chrome browser, When I disable a row works fine in IE but Chrome does nothing, the row still appears normal.

evant
19 Jan 2009, 4:18 AM
What do you mean by "disable" a row?

Can you please post the relevant info as described here: http://extjs.com/forum/showthread.php?t=13985

foronoob
19 Jan 2009, 4:22 AM
sorry, this is the code, (sorry for my english :( )

var selectionModel = grdAdPlannings.getSelectionModel();
var selectedRow = selectionModel.getSelected();
var selRowView = grid.getView().getRow(rowIdx);
selRowView.disabled = true;

Condor
19 Jan 2009, 4:29 AM
Think about what you are doing here: You are disabling a <TR> element.

This is not supported according to the HTML 4 specs (http://www.w3.org/TR/html4/interact/forms.html#adef-disabled). You are lucky that it works on some browsers!

You should try:

grid.getView().addRowClass(rowIndex, 'x-item-disabled');
and maybe some extra code to stop the row from being selected.

evant
19 Jan 2009, 4:39 AM
This definitely isn't an Ext bug, moving it to help.

foronoob
19 Jan 2009, 4:52 AM
Great, now is running OK, thank you all guys for the quick response, excellent group of people ;)

extjsrrr
19 Jan 2009, 5:09 AM
Hi

i need a task the same as u ppl have discussed...


i want to disable a grid cell based on condition...
Condor gave his reply as follows:

You should try:

grid.getView().addRowClass(rowIndex, 'x-item-disabled');
and maybe some extra code to stop the row from being selected.

now, please give me how to stop the row being selected.

thanks in advance...

Condor
19 Jan 2009, 5:30 AM
This example assumes that a row is read-only if myfield contains 'readonly':

var grid = new Ext.data.GridPanel({
...
sm: new Ext.grid.RowSelectionModel({
...
listeners: {
beforerowselect: function(sm, rowIndex, keepExisting, record){
// return false if row is read-only, e.g.
return record.get('myfield') == 'readonly';
}
}
},
viewConfig: {
getRowClass: function(record, rowIndex, rowParams, store){
// return disabled cls if row is read-only, e.g.
if(record.get('myfield') == 'readonly'){
return 'x-item-disabled';
}
}
}
});

ps. If you are using an EditorGridPanel you should also override the ColumnModel isCellEditable method.