在Gwt-Ext中重新渲染combox存储

时间:2022-09-05 20:12:20

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.

我创建了一个表单面板,我在面板中渲染了几个组合框,其中一个商店通过响应处理程序填充。问题,如果我想再次渲染面板,它渲染没有商店的组合框,虽然我正在重新构建面板。我试图调试以找出原因并且令人惊讶的是,虽然对于组合框,Store在调用时为null - comboBox.setStore(store)它检查属性(isRendered)并发现它为true,因此不添加商店但只是保持现有的商店仍然是空的。

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.

我在另一个我已经创建了一个包含Combobox的可折叠字段集的情况下看到了这个问题。在最小化和最大化字段集时,商店因同样的原因而消失。

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

谁可以请帮助我在这里,我完全被击中这里我尝试了各种选择但没有任何作用。

4 个解决方案

#1


2  

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.

无论如何我尝试了别的东西,而调试我发现,虽然我再次点击show按钮创建组件,传递的ID是相同的(这是所需的)但不知何故,对于给定的id,已经有以前的参考可用于Ext.Components。

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

因此,一个简单的解决方案如下: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.

这实际上作为引用导致ComboBox的(isRendered()属性返回true的引用不再可用,因此我可以再次正确地看到商店。

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

我希望这有助于其他面临类似问题的人。不管怎样,谢谢你的回复。

#2


0  

ComboBox.view.setStore() should help.

ComboBox.view.setStore()应该有所帮助。

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是私有变量,请在创建时尝试在Combobox config params之间提及它。如果它没有帮助 - 您可以使用这样的插件:

view_plugin = {

     init: function(o) {

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

and add a line of

并添加一行

plugins: view_plugin,

to Combobox config.

到Combobox配置。

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

然后你可以在代码中稍后调用combobox.setNewStore(newStore)。

#3


0  

You need to write:

你需要写:

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

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:

在你的情况下,并在之前的某个地方定义我的view_pligin代码。或者您甚至可以将其合并到内联中:

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

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.

您也可以在以后随时使用field.setNewStore(store)更改商店。

#4


0  

Have you tried doLayout() method of FormPanel?

你试过FormPanel的doLayout()方法吗?

#1


2  

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.

无论如何我尝试了别的东西,而调试我发现,虽然我再次点击show按钮创建组件,传递的ID是相同的(这是所需的)但不知何故,对于给定的id,已经有以前的参考可用于Ext.Components。

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

因此,一个简单的解决方案如下: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.

这实际上作为引用导致ComboBox的(isRendered()属性返回true的引用不再可用,因此我可以再次正确地看到商店。

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

我希望这有助于其他面临类似问题的人。不管怎样,谢谢你的回复。

#2


0  

ComboBox.view.setStore() should help.

ComboBox.view.setStore()应该有所帮助。

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是私有变量,请在创建时尝试在Combobox config params之间提及它。如果它没有帮助 - 您可以使用这样的插件:

view_plugin = {

     init: function(o) {

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

and add a line of

并添加一行

plugins: view_plugin,

to Combobox config.

到Combobox配置。

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

然后你可以在代码中稍后调用combobox.setNewStore(newStore)。

#3


0  

You need to write:

你需要写:

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

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:

在你的情况下,并在之前的某个地方定义我的view_pligin代码。或者您甚至可以将其合并到内联中:

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

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.

您也可以在以后随时使用field.setNewStore(store)更改商店。

#4


0  

Have you tried doLayout() method of FormPanel?

你试过FormPanel的doLayout()方法吗?