Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS-定义类时如何从构造函数访问值?_Javascript_Extjs_Constructor - Fatal编程技术网

Javascript ExtJS-定义类时如何从构造函数访问值?

Javascript ExtJS-定义类时如何从构造函数访问值?,javascript,extjs,constructor,Javascript,Extjs,Constructor,这里需要帮助。正如您在下面看到的combobox xtype一样,我正试图从typeStore中填充它,但我不确定如何以当前代码布局的方式访问构造函数中的值。这可能吗 此外,字段名“name”和“email”-我试图通过在配置上设置参数来填充它们(但同样,我似乎无法从代码的这一部分访问它们)。通常我会认为它可以通过类似“this.config.params”的东西进行访问,但我真的不确定如何访问它,因为我认为它超出了范围 Ext.define('school',{ extend: 'Ex

这里需要帮助。正如您在下面看到的combobox xtype一样,我正试图从typeStore中填充它,但我不确定如何以当前代码布局的方式访问构造函数中的值。这可能吗

此外,字段名“name”和“email”-我试图通过在配置上设置参数来填充它们(但同样,我似乎无法从代码的这一部分访问它们)。通常我会认为它可以通过类似“this.config.params”的东西进行访问,但我真的不确定如何访问它,因为我认为它超出了范围

Ext.define('school',{
    extend: 'Ext.form.Panel',
    xtype: 'school',
    layout: 'anchor',
    defaultType: 'textfield',
    buttonAlign: 'center',
    items:
        [
            {
                fieldLabel: 'Name',
                name: 'name',
                //value: (?),
                allowBlank:false,
            },
            {
                fieldLabel: 'Email',
                name: 'email',
                //value: (?),
                allowBlank:false,
                vtype: 'email'
            },
            {
                xtype:'combobox',
                fieldLabel: 'Type',
                name: 'types',
                //store: typeStore,
                queryMode: 'local',
                displayField: 'type',
                valueField: 'typeid',
                multiSelect: true,
                emptyText: 'Select type',
                editable: false
            },

您正在使用哪个版本的ExtJs


如果大于等于5,则应该有一个链接到视图的ViewModel。在该viewModel中,您将声明组合所需的存储,以及要作为文本字段值放入的数据

有什么理由不只是将store config放在combobox中吗?@eljkoMitrović如果这真的很明显(对于extjs来说是非常新的),那么我该怎么做呢?谢谢,谢谢你!出于兴趣,如果我在构造器中创建了存储,是否仍然可以按照我最初打算的方式使用它(即在我的组合框中类似于“store:typeStore”)呢?而不是您想象的方式。您必须使用向下选择器找到正确的子项,然后将其设置为“存储”。或者您可以定义全局存储和使用它的id。如果您使用的是更新版本的ExtJS,您可以查看它们的MVVM体系结构。由于模型、视图和控制器是分开的,所以使用它要容易得多
Ext.define('school',{
    extend: 'Ext.form.Panel',
    xtype: 'school',
    layout: 'anchor',
    defaultType: 'textfield',
    buttonAlign: 'center',
    items:
        [
            {
                fieldLabel: 'Name',
                name: 'name',
                //value: (?),
                allowBlank:false,
            },
            {
                fieldLabel: 'Email',
                name: 'email',
                //value: (?),
                allowBlank:false,
                vtype: 'email'
            },
            {
                xtype:'combobox',
                fieldLabel: 'Type',
                name: 'types',
                store: {
                   proxy: {
                       type: 'ajax',
                       url: 'TypesManager',
                       reader: {
                           type: 'json',
                           root: 'items',
                           idProperty: 'typeid'
                       }
                   },
                   fields: ['typeid', 'typename'],
                   autoLoad: true
               },
                queryMode: 'local',
                displayField: 'type',
                valueField: 'typeid',
                multiSelect: true,
                emptyText: 'Select type',
                editable: false
            },
Ext.define('school',{
    extend: 'Ext.form.Panel',
    xtype: 'school',
    layout: 'anchor',
    defaultType: 'textfield',
    buttonAlign: 'center',
    items:
        [
            {
                fieldLabel: 'Name',
                name: 'name',
                //value: (?),
                allowBlank:false,
            },
            {
                fieldLabel: 'Email',
                name: 'email',
                //value: (?),
                allowBlank:false,
                vtype: 'email'
            },
            {
                xtype:'combobox',
                fieldLabel: 'Type',
                name: 'types',
                store: {
                   proxy: {
                       type: 'ajax',
                       url: 'TypesManager',
                       reader: {
                           type: 'json',
                           root: 'items',
                           idProperty: 'typeid'
                       }
                   },
                   fields: ['typeid', 'typename'],
                   autoLoad: true
               },
                queryMode: 'local',
                displayField: 'type',
                valueField: 'typeid',
                multiSelect: true,
                emptyText: 'Select type',
                editable: false
            },