在 Extjs-4 中使用网格重新创建窗口时遇到问题

发布于 2024-11-17 11:19:06 字数 4094 浏览 3 评论 0原文

我需要在窗口中渲染网格组件(通过关闭操作销毁),以便我需要创建新的窗口和网格组件而不是隐藏和显示。

我的代码第一次渲染工作正常,但关闭窗口后,我无法再次创建它,在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 技术交流群。

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

发布评论

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

评论(2

不知在何时 2024-11-24 11:19:06

我遇到了完全相同的问题,并通过将组件创建更改为 工厂函数

原因是 JavaScript 中的对象是通过引用传递,因此在下面的代码片段中,每个网格实例共享相同的列对象:

Ext.define('Adapt.view.versionManager.versionGrdView' ,{
  extend: 'Ext.grid.Panel',
  columns:[
              { header: 'Name',  dataIndex: 'versionName',  flex: 1 },
              { header: 'State', dataIndex: 'versionState', flex: 1 }
          ]
});

使用工厂函数方法,您可以像这样创建网格视图:

Ext.define('Adapt.view.versionManager.versionGrdView' ,{
  extend: 'Ext.grid.Panel',

  initComponent: function() {
    config = Ext.apply({}, { items: this.buildColumns() });
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    this.callParent();
  }

  buildColumns: function() {
    return [
        { header: 'Name',  dataIndex: 'versionName',  flex: 1 },
        { header: 'State', dataIndex: 'versionState', flex: 1 }
    ]
});

现在每个新实例获取自己的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:

Ext.define('Adapt.view.versionManager.versionGrdView' ,{
  extend: 'Ext.grid.Panel',
  columns:[
              { header: 'Name',  dataIndex: 'versionName',  flex: 1 },
              { header: 'State', dataIndex: 'versionState', flex: 1 }
          ]
});

With the factory function approach you create the grid view like this:

Ext.define('Adapt.view.versionManager.versionGrdView' ,{
  extend: 'Ext.grid.Panel',

  initComponent: function() {
    config = Ext.apply({}, { items: this.buildColumns() });
    Ext.apply(this, Ext.apply(this.initialConfig, config));
    this.callParent();
  }

  buildColumns: function() {
    return [
        { header: 'Name',  dataIndex: 'versionName',  flex: 1 },
        { header: 'State', dataIndex: 'versionState', flex: 1 }
    ]
});

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.

绅士风度i 2024-11-24 11:19:06

检查发送来重新配置的列数组。

Check your Column array which is sent to reconfigure.

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