0

コンテナ内に2つのラベルがあります。ボタンをクリックしているときに、ラベルの値を変更したい。私は多くの方法で試しました。しかし、それは変わっていません。

これが私のビューコードです:

   Ext.define('MortgageCalculator.view.CalculateScreen', {
    extend : 'Ext.Panel',

    config : {
        scrollable : true,
        items : [{
            xtype : 'titlebar',
            docked : 'top',
            ui : 'green',
            title : 'MORTGAGE CALCULATOR'
        }, {

            xtype : 'container',
            layout : {
                type : 'vbox'
            },
items : [{

xtype : 'button',
                name : 'submitbtn',
                text : 'Calculate Monthly',
                ui : 'confirm',
                width: 200,
                height : 40,
                margin : 'auto'
            }, {

                xtype : 'container',
                id:'capandintsum',
                layout : {
                    type : 'hbox'
                },
                items : [{
                    xtype : 'label',
                    layout : 'fit',
                    html : 'Capital & Interest',
                    flex : 1,
                    margin : '60 0 0 20'
                }, {
                    xtype : 'label',
                    layout : 'fit',
                    name:'cap&int',
                    id : 'cap&int',
                    html : '0',
                    flex : 1,
                    margin : '60 0 0 20'
                }]
            },

            {
                xtype : 'container',
                layout : {
                    type : 'hbox'
                },
                items : [{
                    xtype : 'label',
                    layout : 'fit',
                    html : 'Interest Only',
                    flex : 1,
                    margin : '20 0 0 20'
                }, {
                    xtype : 'label',
                    layout : 'fit',
                    name:'intonly',
                    id : 'intonly',
                    html : '0',
                    flex : 1,
                    margin : '20 0 0 20'
                }]
        }]
    }
});

そして、コントローラーには以下のコードを使用しています。

Ext.define('MortgageCalculator.controller.Calculate', {         
        extend : 'Ext.app.Controller',
        config : {
            refs : {
                submitbtn : 'button[name=submitbtn]',
                capandintlbl : '#intonly'
                // capandintlbl :  '#cap&int', 
                // onlyintlbl : '#intonly' 
            },
            control : {
                submitbtn : {
                    tap : 'onSubmitButtonTap'
                },
            }
        },


        onSubmitButtonTap : function(button, e, options) {
                                this.getCapandintlbl.setHtml('hello, it is changed');           }



    })

助けてください..

4

2 に答える 2

1

labelの値を設定するだけで、labelで説明されているsetTextメソッドを使用できます。

このリンクを参照してください

 yourLabel.setText('value');
于 2013-01-20T09:09:03.897 に答える
1

最後に私はこの方法で作ることができます:

var me = this; 
var labelfield = me.getCapandintlbl(); 
labelfield.setHtml('it is changing');

ありがとうレイチェル..

于 2013-01-20T13:05:16.503 に答える