PDA

View Full Version : GridPanel w/ RowEditor plugin, can I disable just one cell?



forumuser1080
28 Mar 2011, 4:58 AM
I have a Grid panel with a RowEditor plugin.

My grid has three columns. The second column is a combo box. Based on the selection in the combo box I need to set the editable field on the third column. I.E. my third column is Specify Other. if the user selects 'Other' in the combo box I need the third column to be editable, if anything other than 'Other' is selected I need the third column to be uneditable.

Problem is that I need to do this for each row, i.e. one row could have 'Other' selected and the next ro could not. Meaning I cannot set the entire field to editable/uneditable I need to do it by cell.

Thanks.

mcadirci
28 Mar 2011, 5:18 AM
Add "move" event to one of your fields in the row editor.

It fires every row edit. You can disable the other fields depending on the values.

forumuser1080
28 Mar 2011, 7:35 AM
Not sure this is really what I want. The combo box is in each row of the grid. When you are editing a row you can keep changing your selection in the combo box meaning that the next cell should enable/disable or show/hide with each combo box selection.

I have a listener for the combo box selection changed but I cannot modify the next cell in my grid panel based on the combo box selection.

Any other ideas?

mcadirci
28 Mar 2011, 9:45 PM
First of all you should have one combobox for a column if you are using a rowEditor.
listeners: {
move: function( field ){
//do smt here
},
select: function(){
// do smt here
}
}please try this. move event fires when row editor first opened for the row or on row selection change. And the select event fires when the CB value changed.
These two should work.

forumuser1080
29 Mar 2011, 7:20 AM
Ok that enables me to listen on my combo box but I still have no idea how to disable or hide or 'editable false' for on cell and not the entire column



listeners: {
move: function( field ){
var type = field.getValue();
if (type == 'Other') {
// Ok now I need to get the cell next to me
// and disable it
} else {
// Ok now I need to get the cell next to me
// and enable it
}
},
select: function(combo, record, index){
var type = record.get('type');
if (type == 'Other') {
// Ok now I need to get the cell next to me
// and disable it
} else {
// Ok now I need to get the cell next to me
// and enable it
}
}
}

forumuser1080
29 Mar 2011, 10:47 AM
Back to the original question can you enable/disable show/hide a single cell in a GridPanel with a RowEditor plugin??????

mcadirci
29 Mar 2011, 12:23 PM
Your entire column has only one field for editing.

Add the events to the fields at the columns.


var textField = getTextField();
textField.on('move',handleMove);

....
function handleMove( field ){
if( ! field.isCool() ){
field.setDisabled(true);
else{
field.setDiasbled( false );
}
}

If you need to access other fields give id to fields and access them via Ext.getCmp('fieldId')

forumuser1080
29 Mar 2011, 5:40 PM
'Your entire column has only one field for editing'

Does that mean that I can only disable an entire column not just one cell????



Name Type Specify
------------------------------------------------------
Ford Truck <disable>
Honda Car <disable>
Stroller Other Stroller for my child


Type is a combo box with values (Truck, Car and Other). If the user selects Other in the combo box then the Specify cell for that row should be enabled, otherwise (Truck or Car) the specify row should be disabled.

Is this possible?

mcadirci
29 Mar 2011, 9:49 PM
Yes it is possible just try select&move listener of the combobox it is so easy.