PDA

View Full Version : How to clear value of combo box in grid?



shaoen01
19 Feb 2012, 5:22 AM
Hi All,

I am using grid with roweditor plugin. I have 2 combo boxes called usertype and username. So based on the selection of usertype, the list of usernames will be different. On editing an existing row, initially values will be populated.

So when i select another user type, i want the username combo box to clear current value of the selected record. How do i access the selected record's username combo box and clear the value? Thanks

mitchellsimoens
19 Feb 2012, 6:45 AM
In the beforeedit event, get the field off the editor of the column and remove all the records in the store of the combobox

shaoen01
21 Feb 2012, 4:10 AM
Thanks for the response.

I will be retrieving records from the database. So some rows might already be selected on load. I only want to clear the username combo box when i select another value in the usertype combo box.

shaoen01
24 Feb 2012, 6:00 AM
Anyone has a clue if this is possible? Thanks

Farish
24 Feb 2012, 6:39 AM
if you assign an id to the combobox in the editor

editor:
{
xtype: 'combo',
id: 'id_of_combobox',
store: store_username,
....
}
you can get it using
Ext.getCmp('id_of_combobox'); and clear the value
Ext.getCmp('id_of_combobox').clearValue();

shaoen01
24 Feb 2012, 7:50 AM
if you assign an id to the combobox in the editor

editor:
{
xtype: 'combo',
id: 'id_of_combobox',
store: store_username,
....
}
you can get it using
Ext.getCmp('id_of_combobox'); and clear the value
Ext.getCmp('id_of_combobox').clearValue();

Don't mean to doubt your code, but will it be able to clear the value of the combo box based on the row selected? Don't the "id_of_combobox" be unique?

Farish
24 Feb 2012, 8:31 AM
this id is for the combobox which is in the editor. so it is only one combobox which appears when you start rowediting. give it a try. it should work.

shaoen01
25 Feb 2012, 7:36 AM
this id is for the combobox which is in the editor. so it is only one combobox which appears when you start rowediting. give it a try. it should work.

Yes, it works! Thanks!=D>