extjs 与公式绑定

extjs binding with formulas

我正在尝试使用以下条件在 extjs 中进行文本文件绑定。 我做错了什么?

  1. 需要显示三个文本字段,默认情况下第二个和第三个文本字段将被禁用。
  2. 只有在输入第一个字段值时才应启用第二个文本字段。
  3. 只有在输入第一个和第二个值时才应启用第三个。

the fiddle.

您忘记将第二个字段值绑定到 'field2'。此示例有效:

Ext.application({
  name: 'Fiddle',

  launch: function () {
    Ext.define('MyViewModel', {

        extend: 'Ext.app.ViewModel',

        alias: 'viewmodel.myvm',
        data: {
            field1: '',
            field2: '',
            field3: ''
        },
        formulas: {
            fieldTwoDisabled: function (get) {
                return Ext.isEmpty(get('field1'));
            },
            fieldThreeDisabled: function (get) {
                return !(!Ext.isEmpty(get('field1')) && !Ext.isEmpty(get('field2')));
            }
        }

    });


    Ext.create({
        xtype: 'panel',
        title: 'VM Demo',
        fullscreen: true,
        defaults: {
            xtype: 'textfield'
        },
        viewModel: {
            type: 'myvm'
        },

        items: [{
            label: 'Field 1',
            bind: '{field1}'
        }, {
            label: 'Field 2',
            bind: {
                value: '{field2}', // THIS BINDING IS FORGOTTEN
                disabled: '{fieldTwoDisabled}'
            }
        }, {
            label: 'Field 3',
            bind: {
                disabled: '{fieldThreeDisabled}'
            }
        }]
    })
  }
});