View Full Version : getForm().reset() only clears selection and not content.

7 Oct 2016, 6:37 AM
I have a search form which has few textboxes and drop down comboboxes , a seach button and a clear button

after i select few selections in comboboxes and type text content in textboxes, on clearButton action i am able to erase the displayed content in those boxes using below command


But this command only clears the content //displayed// in textboxes and comboboxes, the items in the comboboxes will be still available after form is reset. What i mean to say is even after i reset, if i click the drop down menu in comboboxes, it still shows the items available for selection.

So is there any way to clear the items in drop downs as well. As in reset the store itself so that regardless of whether the form has textbox or combobox, it shouldnt show contents.

i know the workaround, i could just loop through the items in the form and clear the store one by one

as in loop around below code from 0-n and remove the contents one by one.

me.getSearchForm().getForm().getFields().items[ i ].getStore().removeAll();

I would like to avoid looping if possible. So is there any better way to do this without the loop?

any help is deeply appreciated.

Gary Schlosberg
7 Oct 2016, 9:14 AM
Are you talking about clearing values that the user has entered into the combo (forceSelection:false)?

9 Oct 2016, 11:49 PM
No, for clearing just the values selected by a user i can run the command :

what i want to achieve is clear the store from the form boxes. even if i run the above command it will just clear the selection, but if i click the drop down menu from combobox, i can still see the fetched values from the DB.

10 Oct 2016, 7:27 AM
I think this is a very unusual case and there aren`t any ways to do what you want with standard methods.
You should extend Ext.form.Base and change method reset like this:

reset: function(resetRecord) {

var me = this,
fields = me.getFields().items,
fLen = fields.length;

for (f = 0; f < fLen; f++) {

// check if this is combobox
if (fields[f].getStore) {
// clear store


if (resetRecord === true) {
delete me._record;
return me;

12 Oct 2016, 7:27 AM
Thanks nikolaich (https://www.sencha.com/forum/member.php?79531-nikolaich). I implemented something similiar to this.

appreciate the solution.