更改活动选项卡后未加载Extjs存储(Extjs store isn't loaded after changing active tab)

编程入门 行业动态 更新时间:2024-10-25 02:21:07
更改活动选项卡后未加载Extjs存储(Extjs store isn't loaded after changing active tab)

我有一个grid.panel,旁边有表名,我想在用户点击它时,在标签视图中的另一个grid.panel中显示表(或它的结构)。

我做了什么:

在actionlistener中

var store = Ext.data.StoreManager.lookup('Tables'); currentTable = store.findRecord('name',record.get('name')); var structureView = Ext.ComponentQuery.query('structure')[0]; structureView.showTable(currentTable);

在视图中

showTable: function(table) { this.storeObj.getProxy().url = '/tables/stucture/' + table.data.name; this.storeObj.load(); this.update(); }

在Tables存储库中,我有表描述符,有一些基本数据,如名称等,带有表名的列表显示了这个商店的内容。 因此,我查找Tables存储并获取tabledescriptor并将其传递给视图,然后视图将加载存储(在本例中为“Columns”)及其将显示的数据。 所有这一切都正常,直到我切换标签。 更改活动选项卡然后更改后备数据时,单击另一个表的名称不会刷新,我得到:未捕获TypeError:无法调用null的方法'removeChild'。 在更改活动选项卡后,它似乎无法再加载商店。 我在论坛上发现了这个问题,但我找不到解决方案。

你有什么想法?

谢谢你的时间。

编辑:

Ext.define('App.view.Table.Structure', { extend: 'Ext.grid.Panel', alias: 'widget.structure', store: 'Columns', width: 800, storeObj: undefined, initComponent: function () { this.columns = [{ header: 'Column name', dataIndex: 'name', flex: 1 }, { header: 'Position', dataIndex: 'position', flex: 1 }, { header: 'Default value', dataIndex: 'defaultValue', flex: 1 }, { header: 'Column type', dataIndex: 'type', flex: 1 }, ]; this.storeObj = Ext.StoreManager.lookup('Columns'); this.callParent(arguments); }

I have a grid.panel on the side with table names and I'd like to show the table(or it's structure) when the user clicks on it, in another grid.panel inside a tab view.

what i did:

in the actionlistener

var store = Ext.data.StoreManager.lookup('Tables'); currentTable = store.findRecord('name',record.get('name')); var structureView = Ext.ComponentQuery.query('structure')[0]; structureView.showTable(currentTable);

in the view

showTable: function(table) { this.storeObj.getProxy().url = '/tables/stucture/' + table.data.name; this.storeObj.load(); this.update(); }

In the Tables store I have table descriptors, with some basic data like name, etc. and the list with table names displays the content of this store. So I look up the Tables store and get the tabledescriptor and pass it to the view, which then loads the store('Columns' in this case) with the data it will display. And all this works fine until I switch tabs. After changing the active tab and then changing back data is not refreshed on clicking on another table's name and I get this: Uncaught TypeError: Cannot call method 'removeChild' of null. It seems that it can't load the store anymore after changing the active tab. I found this issue on forums but I couldn't find a solution for it.

Do you have any ideas?

Thanks for your time.

Edit:

Ext.define('App.view.Table.Structure', { extend: 'Ext.grid.Panel', alias: 'widget.structure', store: 'Columns', width: 800, storeObj: undefined, initComponent: function () { this.columns = [{ header: 'Column name', dataIndex: 'name', flex: 1 }, { header: 'Position', dataIndex: 'position', flex: 1 }, { header: 'Default value', dataIndex: 'defaultValue', flex: 1 }, { header: 'Column type', dataIndex: 'type', flex: 1 }, ]; this.storeObj = Ext.StoreManager.lookup('Columns'); this.callParent(arguments); }

最满意答案

好吧,我终于设法解决了,但我真的不明白为什么这解决了这个问题。 所以这就是我做的:

每当我需要更新Columns存储(或其他)时,我都会查找它,而不是仅仅在initcomponent中查找它。 我没有调用update()方法,而是调用了reconfigure()

现在它就像魅力一样,但我不明白为什么更新没有做到这一点,为什么每次我想在它上面调用load()时都要查看商店...所以如果有人能解释它我会很感恩的。

Well I managed to solve it at last, but I don't really understand why this solved the problem. So this is what I did:

Every time I needed to update the Columns store(or the others) I looked it up instead of just looking it up in the initcomponent. Instead of calling update() method I called reconfigure()

Now it works like charm, but I don't see why update didn't do the trick and why I had to look up the store every time I wanted to call load() on it... So if someone could explain it I would be thankful.

更多推荐

本文发布于:2023-08-07 04:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459563.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡   加载   Extjs   store   tab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!