在 Gwt-Ext 中重新渲染组合框存储

发布于 2024-07-06 06:16:38 字数 343 浏览 8 评论 0原文

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

我在另一个场景中看到了这个问题,我创建了一个包含组合框的可折叠字段集,在最小化和最大化字段集时,商店会因为同样的原因消失。

有人可以在这里帮助我吗,我在这里完全震惊了,我尝试了各种选择,但没有任何效果。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撞了怀 2024-07-13 06:16:38

感谢您的评论,实际上我尝试了插件方法,但无法完全理解它如何获取不是组件公开元素的商店的句柄。

无论如何,我尝试了其他方法,在调试时,我发现虽然我在单击显示按钮时再次创建组件,但传递的 ID 是相同的(这是所需的),但不知何故,对于给定的 id,已经在外部组件。

因此,一个简单的解决方案如下:
组件 comp = Ext.getCmp(id);
if ( comp != null )
comp.destroy();

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

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

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.

网名女生简单气质 2024-07-13 06:16:38

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

如果视图是私有变量,只需在创建时尝试在 Combobox 配置参数之间提及它。 如果它没有帮助 - 您可以使用这样的插件:

view_plugin = {

     init: function(o) {

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

添加一行

plugins: view_plugin,

并向Combobox 配置

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

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.

旧街凉风 2024-07-13 06:16:38

您需要编写:

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

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

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

在插件内部,所有私有属性和方法都是可访问/可更改的。

您还可以在以后随时使用 field.setNewStore(store) 更改存储。

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.

岛歌少女 2024-07-13 06:16:38

您是否尝试过 FormPaneldoLayout() 方法?

Have you tried doLayout() method of FormPanel?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文