在 Extjs-4 中使用网格重新创建窗口时遇到问题
我需要在窗口中渲染网格组件(通过关闭操作销毁),以便我需要创建新的窗口和网格组件而不是隐藏和显示。
我的代码第一次渲染工作正常,但关闭窗口后,我无法再次创建它,在layout.js
行上遇到问题:150 错误:类型不匹配。
************ getting issue in the below method and "dom" is undefined*********
moveItem : function(item, target, position) {
// Make sure target is a dom element
target = target.dom || target;
if (typeof position == 'number') {
position = target.childNodes[position];
}
target.insertBefore(item.el.dom, position || null); //dom is undefined
item.container = Ext.get(target);
this.configureItem(item);
this.childrenChanged = true;
}
************
My controller and view of(grid and window) i have attached .Please identify where i am going wrong
************
Code:
**************************************************************************
Window Controller
**************************************************************************
Ext.define('Adapt.controller.versionManager.verManWinCont', {
extend : 'Ext.app.Controller',
views : ['versionManager.verManWinView'],
init : function() {
this.control({
'verManWindow' : {
afterrender : this.verManWindowAfterRender
}
});
},
verManWindowAfterRender : function(win, options) {
});
**************************************************************************
window View
**************************************************************************
Ext.define('Adapt.view.versionManager.verManWinView' ,{
extend: 'Ext.window.Window',
requires: ['Adapt.controller.versionManager.versionCont','Adapt.view.versionManager.versionGrdView', 'Adapt.store.versionManager.versionStor'],
alias : 'widget.verManWindow',
constructor: function (config) {
this.callParent([config]);},
layout: 'fit',
closeAction :'destroy',
items: [{xtype: 'versionGrd'}],
autoShow :true,
width : 580,
height : 338,
closable : true,
plain : true
});
**************************************************************************
Grid Controller
**************************************************************************
Ext.define('Adapt.controller.versionManager.versionCont', {
extend : 'Ext.app.Controller',
views : ['versionManager.versionGrdView'],
stores : ['versionManager.versionStor'],
models : 'Adapt.model.versionManager.versionModl',
init : function() {
debugger;
this.control({
'versionGrd' : {
itemdblclick : this.versionGridDoubleClick,
afterrender : this.versionGridAfterRender
}
});
},
versionGridAfterRender : function(grid, options) {debugger;
}
});
**************************************************************************
Grid View
**************************************************************************
Ext.define('Adapt.view.versionManager.versionGrdView' ,{
extend: 'Ext.grid.Panel',
requires: ['Ext.grid.*','Adapt.view.versionManager.versionCreateView'],
alias : 'widget.versionGrd',
store: 'versionManager.versionStor',
columns:[
{header: 'Name', dataIndex: 'versionName', flex: 1},
{header: 'State', dataIndex: 'versionState', flex: 1}
],
constructor: function (config) {debugger;
this.callParent([config]);},
dockedItems: []
});
************************************************************************
(creating and showing in this handler)
In viewport Toolbar button handler(Controller)
this.getController('versionManager.verManWinCont');
this.getController('versionManager.versionCont');
new Adapt.view.versionManager.verManWinView();//.show();
感谢您抽出时间 维诺德
I need to render grid component with in the window(with close action destroy) so that i need to create new window and grid component instead of hide and show.
My code is working fine for the first time render but after closing window , i am unable to create it again, getting issue on layout.js
Line: 150
Error: Type mismatch.
************ getting issue in the below method and "dom" is undefined*********
moveItem : function(item, target, position) {
// Make sure target is a dom element
target = target.dom || target;
if (typeof position == 'number') {
position = target.childNodes[position];
}
target.insertBefore(item.el.dom, position || null); //dom is undefined
item.container = Ext.get(target);
this.configureItem(item);
this.childrenChanged = true;
}
************
My controller and view of(grid and window) i have attached .Please identify where i am going wrong
************
Code:
**************************************************************************
Window Controller
**************************************************************************
Ext.define('Adapt.controller.versionManager.verManWinCont', {
extend : 'Ext.app.Controller',
views : ['versionManager.verManWinView'],
init : function() {
this.control({
'verManWindow' : {
afterrender : this.verManWindowAfterRender
}
});
},
verManWindowAfterRender : function(win, options) {
});
**************************************************************************
window View
**************************************************************************
Ext.define('Adapt.view.versionManager.verManWinView' ,{
extend: 'Ext.window.Window',
requires: ['Adapt.controller.versionManager.versionCont','Adapt.view.versionManager.versionGrdView', 'Adapt.store.versionManager.versionStor'],
alias : 'widget.verManWindow',
constructor: function (config) {
this.callParent([config]);},
layout: 'fit',
closeAction :'destroy',
items: [{xtype: 'versionGrd'}],
autoShow :true,
width : 580,
height : 338,
closable : true,
plain : true
});
**************************************************************************
Grid Controller
**************************************************************************
Ext.define('Adapt.controller.versionManager.versionCont', {
extend : 'Ext.app.Controller',
views : ['versionManager.versionGrdView'],
stores : ['versionManager.versionStor'],
models : 'Adapt.model.versionManager.versionModl',
init : function() {
debugger;
this.control({
'versionGrd' : {
itemdblclick : this.versionGridDoubleClick,
afterrender : this.versionGridAfterRender
}
});
},
versionGridAfterRender : function(grid, options) {debugger;
}
});
**************************************************************************
Grid View
**************************************************************************
Ext.define('Adapt.view.versionManager.versionGrdView' ,{
extend: 'Ext.grid.Panel',
requires: ['Ext.grid.*','Adapt.view.versionManager.versionCreateView'],
alias : 'widget.versionGrd',
store: 'versionManager.versionStor',
columns:[
{header: 'Name', dataIndex: 'versionName', flex: 1},
{header: 'State', dataIndex: 'versionState', flex: 1}
],
constructor: function (config) {debugger;
this.callParent([config]);},
dockedItems: []
});
************************************************************************
(creating and showing in this handler)
In viewport Toolbar button handler(Controller)
this.getController('versionManager.verManWinCont');
this.getController('versionManager.versionCont');
new Adapt.view.versionManager.verManWinView();//.show();
Thanks for your time
vinod.P
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了完全相同的问题,并通过将组件创建更改为 工厂函数。
原因是 JavaScript 中的对象是通过引用传递,因此在下面的代码片段中,每个网格实例共享相同的列对象:
使用工厂函数方法,您可以像这样创建网格视图:
现在每个新实例获取自己的columns数组副本,解决了部分配置被破坏的问题。作为一个很好的副作用,我还注意到,由于我只使用工厂方法,应用程序的启动次数减少了。
I had exactly the same problem and solved it by changing the component creation to factory functions.
The reason is that objects in JavaScript are passed by reference, so in the snippet below every grid instance shares the same columns object:
With the factory function approach you create the grid view like this:
Now every new instance get its own copy of the columns array, which solves the problem that a part of the configuration has been destroyed. As a nice side effect, I also noticed that the startup of the application has reduced since I use only factory methods.
检查发送来重新配置的列数组。
Check your Column array which is sent to reconfigure.