简体   繁体   English

Ext.Viewport.add不是Ext js中的函数

[英]Ext.Viewport.add is not a function In Ext js

I am very new to Ext js . 我是Ext js的新手。 I am trying to implement Grid in application in that once user will click on data new msg window will open with current data and user can edit that and this will saved in model. 我正在尝试在应用程序中实现Grid,因为一旦用户单击数据,新的msg窗口将打开并显示当前数据,用户可以对其进行编辑并将其保存在模型中。 I am using Classic toolkit 我正在使用经典工具包

I tried like this: 我这样尝试过:

Ext.define('MyApp.view.main.MainController', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.main',
    require:['Ext.plugin.Viewport'],

    itemtap: function (view,index,item,record) {
       Ext.Viewport.add({
       xtype:'formpanel',
       title:'update',
       width:300,
       centered: true,
       modal: true,
       viewModel : {
                        data: {
                            employee: record
                        }
                    },
       items: [{

                        xtype: 'textfield',
                        name: 'firstname',
                        label: 'First Name',
                        bind: '{employee.name}'

                    }, {
                        xtype: 'toolbar',
                        docked: 'bottom',
                        items: ['->', {
                            xtype: 'button',
                            text: 'Submit',
                            iconCls: 'x-fa fa-check',
                            handler: function() {
                                this.up('formpanel').destroy();
                            }
                        }, {
                            xtype: 'button',
                            text: 'Cancel', 
                            iconCls: 'x-fa fa-close',
                            handler: function() {
                                this.up('formpanel').destroy();
                            }
                }]
           }]
     })

and In my other file i am calling this function like 在我的另一个文件中,我像这样调用此函数

listeners: {
        select: 'itemtap'
    }

But i am getting error like Ext.Viewport.add is not a function 但是我遇到像Ext.Viewport.add这样的错误,不是一个函数

Kindly suggest me how can i make it possible . 请建议我如何使之成为可能。

Any suggestions are welcome . 任何建议都欢迎。

In classic toolkit, you don't have a viewport that shows only a single item every time. 在经典工具包中,您没有每次只能显示一个项目的视口。 The whole concept of a viewport that you want to add components to at runtime is a concept of the modern toolkit. 您想要在运行时向其添加组件的视口的整个概念是现代工具箱的概念。

Instead, you can put your form inside a Window: 相反,您可以将表单放在Window中:

var window = Ext.create('Ext.window.Window',{
   title:'update',
   width:300,
   centered: true,
   modal: true,
   items: [{
       xtype:'formpanel'
       viewModel : {
                    data: {
                        employee: record
                    }
                },
   ...

})
window.show();

And your handlers should close/destroy the window, not just destroy the formpanel: 并且您的处理程序应该关闭/销毁窗口,而不仅仅是销毁表单面板:

this.up('window').close();
this.up('window').destroy();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM