如何在 Ext.js 中绑定我自己的对象配置?

问题描述 投票:0回答:1

我创建了一个扩展“Ext.form.field.Base”的自定义对象,并设置了一些自定义对象配置来控制其子组件的可见性。但是,因为这是我自己的配置,所以无法绑定。

这个自定义对象有一个子对象,一个名为“fileedit”的输入文件,fileedit 子组件是按钮(发送文件、删除文件、下载)。我正在尝试使用 viewModel 控制这些按钮的可见性。我无法直接绑定可见性,我必须通过自定义对象配置来完成。如果不展示代码就很难解释这个结构,而且我无法发送它,因为它已经在生产环境中了。

我的疑问是:有什么方法可以使自定义配置可绑定吗?

   {
       xtype: 'fileedit',
       bind: {
           canDownload: '{canDownload}',
           canShowFileName: '{canShowFileName}',
           canClearImg: '{canClearImg}',
           canSendFile: '{canSendFile}', 
       },
       height: 180,
       listeners: {
           onFileChange: 'onFileChange',
           onAfterUploadFile: 'onAfterUploadFile'
       }
   }
extjs viewmodel bind bindable
1个回答
0
投票

您可以在自定义组件中使用twoWayBindable配置。

像这样;

config: {
    canDownload: null,
    canShowFileName: null,
    ...
},
twoWayBindable: ['canDownload', 'canShowFileName', ...],

检查组件文档中的twoWayBindable 配置。

© www.soinside.com 2019 - 2024. All rights reserved.