开发者

Disabling FieldSet items when it is collapsed

I have Ext.form.FieldSet wit开发者_如何学JAVAh some fields in it. It looks like:

var register_options = new Ext.form.FieldSet({
    autoHeight: true,
    title: 'My Title',
    checkboxToggle: true,
    checkboxName: 'register_options',
    items: [item1, item2, item3]
});

When my fieldset checkbox is unchecked (fieldset is collapsed) i don't want submit any of its fields (item1, item2...).

I can do this by adding some listeners and disabling fields:

listeners: {
    collapse: function(p) {
        p.items.each(function(i) {
            i.disable();
        },
        this);
    },
    expand: function(p) {
        p.items.each(function(i) {
            i.enable();
        },
        this);
    }
}

Is it proper way, how can i do this better?


I don't see anything wrong with your code as long as it works. An alternate that is not as elegant would involve using the cascade function to drill down into the containers.


Yeah, the cascade function (as suggested by IT Grunt above) worked for me:

listeners: {
    collapse: function(p) {
        p.cascade(function () {
            this.disable();
        });
    },
    expand: function(p) {
        p.cascade(function () {
            this.enable();
        });
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜