PDA

View Full Version : [SOLVED] enable/disable textfield when item combobox is selected



jimmyful
2 Jul 2010, 1:06 PM
I use an Ext.ux.grid.RowEditor plugin in a gridpanel. I put two columns in the grid panel a combobox and a textfield. I need to set enable / disable the textfield when I select an item from combo box. this is my code. thank you regards.


//roweditor definition
var editor = new Ext.ux.grid.RowEditor({
saveText: 'Grabar'
});

//gridpanel definition
var grid = new Ext.grid.GridPanel({
renderTo: document.body,
enablecolumnmove:true,
title: 'Informacion',
store: dsgrid,
frame:true,
height:200,
width:1000,
region:'center',
plugins: [editor],
tbar: [{
text: 'Agregar Registro',
handler: function(){
var e = new dr_grid({
type:'',
concepto:''});
editor.stopEditing();
dsgrid.insert(0, e);
grid.getView().refresh();
grid.getSelectionModel().selectRow(0);
editor.startEditing(0);
}
},{ text: 'Remover registro',
disabled: true,
handler: function(){
editor.stopEditing();
var s = grid.getSelectionModel().getSelections();
for(var i = 0, r; r = s[i]; i++){
dsgrid.remove(r);
}
}
}],
columns: [{header: "Type", dataIndex: 'type',editor: cmbtype, renderer:cmbtype(cmbtype)},
{header: "concepto", dataIndex: 'concepto', editor: concepto}]
});

//this is de event select
cmbtype.on ('select',function(){

if (Ext.util.Format.uppercase(tipo)=='JURIDICA')
{
concepto.disabled=true; //this is the problem, without error but doesn't work.
}
else
{
concepto.disabled=false;
}


});

prophet
2 Jul 2010, 1:24 PM
See this post (http://www.sencha.com/forum/showthread.php?29791-EditorGridPanel-disable-editor-for-certain-fields&p=139783#post139783)

Condor
2 Jul 2010, 11:25 PM
isCellEditable won't work on a RowEditor.

The problem with your code is that your are changing the read-only property 'disabled'. You should be using the setDisabled method intead.

4 Jul 2010, 9:07 AM
Please post code within [ CODE ] tags in the future.

jimmyful
5 Jul 2010, 7:46 AM
Thank you, setDisabled works fine.


if (Ext.util.Format.uppercase(tipo)=='JURIDICA')
{
concepto.setDisabled(true);
}
else
{
concepto.setDisabled(false);
}

5 Jul 2010, 7:47 AM
you have to close the code tag [ /code ]

5 Jul 2010, 7:48 AM
And you can simplify your code by doing:


concepto.setDisabled(Ext.util.Format.uppercase(tipo) === 'JURIDICA');

jimmyful
5 Jul 2010, 7:50 AM
Thanks a lot.