我有一个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.
更多推荐
发布评论