PDA

View Full Version : Disable cells in a row on the basis of dropdown value selected in that row !!



jsharma
12 Aug 2009, 3:06 AM
Hello ''

Ok I have a datagrid '' lets assume it has 10 rows and 10 columns. Now, say one column of the 10 columns has dropdown values. So, now I want disable specific cells in the row on the basis of dropdown value selected for that row. Say if dropdown value is X, cells in that row for columns say C1, C8, C9 will become disable, if dropdown value is Y, cell in that row for columns say C2, C5 will become disable and so on.... I didn't found any specific api to disable the cells this way. I used this code snippet in my columnmodel section at the end ::
.......................................
.......................................
.......................................
, isCellEditable: function(col, row) {
var record = store.getAt(row);
if (record.get('category') == 'Allowance')
{
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});
........................................
.........................................
.......................................
Above, category is a column name for dropdown and "Allowance" is a value !! With above code the problem is, full row becomes disable instead of specific cells in the row. I don't know what API to use addtionally in the code above to make it work my way :-?

pdegit
12 Aug 2009, 3:08 AM
The isCellEditable method will be called for each row/col combination, however, you never check the col number for which isCellEditable is called. You're only checking the dropdown value and then returning false for all columns in a row if it has a certain value...

Make sure you check the value of col to see which column you're enabling/disabling.


.......................................
.......................................
.......................................
, isCellEditable: function(col, row) {
var record = store.getAt(row);
if (record.get('category') == 'Allowance' && col == <whatever column number you want to disable>)
{
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});
........................................
.........................................
.......................................

jsharma
12 Aug 2009, 4:53 AM
Hi pdegit (http://extjs.com/forum/member.php?u=42793)''

the last reply helped but, it works for disabling just one cell in a row at a time. Say'''

.......................................
.......................................
.......................................
, isCellEditable: function(col, row) {
var record = store.getAt(row);
if (record.get('category') == 'Allowance'&& col == 5)
{
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});
........................................
.........................................
.......................................

In above example, for row containing value Allowance as dropdown value, only value at column 5 will gets disabled. Say, cell (2, 5) only gets disabled. But what if I also want to disable cells (2, 6), (2, 7), (2, 9) for the same row number 2. I hope you got me ? Thnx for the last reply pdegit (http://extjs.com/forum/member.php?u=42793).

mystix
12 Aug 2009, 7:39 AM
@jsharma, this may help:
http://extjs.com/forum/showthread.php?t=43576

note: it was written for Ext 2.x, so YMMV.

pdegit
12 Aug 2009, 11:36 AM
Hi pdegit (http://extjs.com/forum/member.php?u=42793)''

the last reply helped but, it works for disabling just one cell in a row at a time. Say'''

.......................................
.......................................
.......................................
, isCellEditable: function(col, row) {
var record = store.getAt(row);
if (record.get('category') == 'Allowance'&& col == 5)
{
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});
........................................
.........................................
.......................................

In above example, for row containing value Allowance as dropdown value, only value at column 5 will gets disabled. Say, cell (2, 5) only gets disabled. But what if I also want to disable cells (2, 6), (2, 7), (2, 9) for the same row number 2. I hope you got me ? Thnx for the last reply pdegit (http://extjs.com/forum/member.php?u=42793).


How 'bout this... Hope this helps you understand better how and when isCellEditable is called...

.......................................
.......................................
.......................................
, isCellEditable: function(col, row) {
var record = store.getAt(row);
if ((record.get('category') == 'Allowance'&& (col == 5 || col == 7))
{
return false;
}
return Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, row);
}
});
........................................
.........................................
.......................................

jsharma
12 Aug 2009, 10:56 PM
That worked .. thnx a lot ''