ExtJS 5.1: Binding record value to component property

前端 未结 1 1696
滥情空心
滥情空心 2020-12-22 10:06

Let\'s say I\'ve got a ViewController, ViewModel, and my View. In the View, I\'ve got a form panel that gets a loaded record. When this record loads into the form, I want to

相关标签:
1条回答
  • 2020-12-22 10:46

    If your record is part of the view model data - use formulas, like:

    formulas: {
        hideDeleteButton: function (getter) {
            return getter('record.status') === 2;
        },
        hideAddButton: function (getter) {
            return getter('record.status') === 1;
        }
    }
    

    And then in your view you can bind:

    {
        text: 'Add',
        reference: 'addButton',
        bind: {
            hidden: '{hideAddButton}'
        }
    }, {
        text: 'Delete',
        reference: 'deleteButton',
        bind: {
            hidden: '{hideDeleteButton}'
        }
    }
    

    A working example: https://fiddle.sencha.com/#fiddle/mcg

    0 讨论(0)
提交回复
热议问题