Ashwani
Ashwani

Reputation:

re-rendering of combox store in Gwt-Ext

i've created a Form Panel, and i'm rendering couple of Combo Boxes in the panel with a store which is populated via an response handler. the problem if i want to render the panel again it renders the combo boxes without the store, though i'm re-constructing the panel. i tried to debug to figure out the cause and surprisingly though for combo box the Store is null on calling - comboBox.setStore(store) it checks for the property (isRendered) and finds it to be true and hence doesn't add the store but just keep the existing store which is still null.

i've seen this problem in another scenaio where i had created a collapsible field set containing the Combobox, On minimize and maximize of the fieldset the store vanishes for the same reasons.

can someone please help me here, i'm completely struck here i tried various option but nothing works.

Upvotes: 4

Views: 4367

Answers (4)

Thevs
Thevs

Reputation: 3253

Have you tried doLayout() method of FormPanel?

Upvotes: 0

Thevs
Thevs

Reputation: 3253

You need to write:

field = new ComboBox({plugins: view_plugin});

In your case and define my code of view_pligin somewhere before. Or you can even incorporate it inline:

field = new ComboBox({plugins: { code of plugin });

Inside plugin all private properties and methods are accessible/changeable.

You also can change store using field.setNewStore(store) at any time later on.

Upvotes: 0

Ashwani
Ashwani

Reputation:

Thanks for your comments, actually i tried the plugin approach but couldn't understand it completely as to how will i get the handle to the store which is not an exposed element of the component.

Anyways i tried something else, while debugging i found that though i'm creating the component again on click of show button, the ID passed is same ( which is desired ) but somehow for the given id there is already the previous reference available in the Ext.Components.

Hence an easy solution is following : Component comp = Ext.getCmp(id); if ( comp != null ) comp.destroy( );

this actually worked as the reference which was causing the ( isRendered( ) property of the ComboBox to return true is no more available and hence i can see the store again properly.

i hope this helps others who are facing similar issue. Thanks anyways for replying.

Upvotes: 2

Thevs
Thevs

Reputation: 3253

ComboBox.view.setStore() should help.

If view is a private variable, just try to mention it between Combobox config params when creating. If it doesn't help - you can use plugin like that:

view_plugin = {

     init: function(o) {

          o.setNewStore = function(newStore) {
              this.view.setStore(newStore);
          };
     }
};

and add a line of

plugins: view_plugin,

to Combobox config.

Then you can call combobox.setNewStore(newStore) later in the code.

Upvotes: 0

Related Questions