PDA

View Full Version : Determining if all of the container children are loaded.



mx_starter
12 Apr 2013, 6:57 AM
Howdy all,
a have a form panel which may contain a dynamic/unknown number of children fields.

For example, there could be 10 different combo-boxes within - each with different stores/data.
And these combos are instantiated and added to the form panel by the script, immediately before the panel is shown.

Each combo is loading its store upon creation and after that - a combo value is set.

Well - i want to mask the form panel using something like a 'waiting' indicator until all combos are populated and set with the appropriate value - something like the loadMask with grids.

Any suggestions are welcome, thanks in advance.

mx_starter
12 Apr 2013, 8:31 AM
Of course, using Ext.LoadMask is a possible approach, however, it can use only one store...

mx_starter
14 Apr 2013, 11:54 PM
Question unclear ot solution impossible? ;)
Come on, i'm sure you have ideas....

tvanzoelen
15 Apr 2013, 12:07 AM
I also use forms with a dynamic number of fields on it. But I know how many fields to expect even when dynamic. On the render event of a field I count the the number of fields rendered, wheb all fields which are expected are renderen I flag the form to be renderen and it is possible to edit the form. With comboboxes I listen to the load event of its store, and I flag them of as rendered.

So an option is, when you know beforehand to number of items - which you should be able to calculate somewhere, that you flag them off as rendered.

mx_starter
15 Apr 2013, 5:15 AM
I also use forms with a dynamic number of fields on it. But I know how many fields to expect even when dynamic. On the render event of a field I count the the number of fields rendered, wheb all fields which are expected are renderen I flag the form to be renderen and it is possible to edit the form. With comboboxes I listen to the load event of its store, and I flag them of as rendered.

So an option is, when you know beforehand to number of items - which you should be able to calculate somewhere, that you flag them off as rendered.

To be honest, initially i considered something similar ( if not exactly the same :) ).
The number of the components could be determined before the form-panel is shown.
So - this approach will include 2 variables - one which will keep the total expected components and a separate one which will be incremented each time a combo is loaded its store.

However, it looks too boring I-| ...
Moreover, the loading of the form finishes with a frm.getForm().setValues() call which is used to choose a combo value after the combos are loaded the stores.

So, may be i must ask for an event which fires after the form's setValues() method finishes its work...

tvanzoelen
15 Apr 2013, 5:27 AM
Just override the setValues method in the basic form and create a hook there or let it fire an event.

mx_starter
15 Apr 2013, 6:01 AM
Just override the setValues method in the basic form and create a hook there or let it fire an event.

some example if it is not too long?

tvanzoelen
15 Apr 2013, 6:10 AM
Ext.override(Ext.form.Basic, {

setValues: function(record, callback){

this.callParent(arguments);

if(callback){
callback(this, record);
}
}


});