ExtJS 6-将禁用的属性绑定到商店中的新记录 [英] ExtJS 6 - Bind disabled property to new records in a store

查看:117
本文介绍了ExtJS 6-将禁用的属性绑定到商店中的新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当商店的getNewRecords()函数返回长度时,我试图启用/禁用按钮,但是不起作用!

I'm trying to enable/disable a button when the store getNewRecords() function return the length, but not work!

bind: {
  disabled: "{!grid.getStore().getNewRecords().length}"
}

小提琴: https://fiddle.sencha.com/fiddle/1sj5

有人知道如何解决这个问题?

Someone have idea to how resolve this?

推荐答案

您需要在视图模型中创建一个公式:

You need to create a formula in your viewmodel:

viewModel: {
    formulas: {
        hasNewRecords: function (r) {
            return this.getView().down("treepanel").getStore().getNewRecords().length > 0;
        }
    }
}

然后您可以将其用于绑定:

then you can use it for your bindings:

bind: {
    disabled: "{hasNewRecords}"
}

(可能不是获取所需数据的最佳方法).

(probably not the best way to get the data you want).

您可以阅读此处此处此处.

这篇关于ExtJS 6-将禁用的属性绑定到商店中的新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆