0

我需要在表单面板中更改我的标题

这是我的代码

view.js

    Ext.define('bluebutton.view.BlueButton.Loyalty', {
    extend: 'Ext.Container',
    xtype: 'loyaltycard',
       requires: [

    'bluebutton.view.BlueButton.TransactionList',
    'bluebutton.view.BlueButton.MemberPopUp',
     'bluebutton.view.BlueButton.MemberDetail',

      'bluebutton.view.BlueButton.CouponMain',

     'bluebutton.store.BlueButton.MemberList',
     'bluebutton.store.BlueButton.CouponList',

    'Ext.ux.keypad.Keypad',
    'Ext.Img',
    'Ext.carousel.Carousel'



    ],
    config: {
//        iconCls: 'add_black',
//        title :'Loyalty Point',
        styleHtmlContent: true,
        cls: 'styledContent',
//        
         layout: 'hbox',
         border: 3,
         ui: 'round',

         defaults: {
                margin : '10 10 10 10',
                 padding : 10
             },

        items :[


           {
                flex: 1,

                xtype :'formpanel',
                 id:'loyaltyform',
                items :[
                    {
                         xtype: 'fieldset',
                         cls :'containerRadious' ,

                        title: 'Welcome, new member ~<i><u>Kenny</u></i>',
                          defaults: {
                            labelWidth: '35%',
                            style: 'font-size:1.0em'
                        },
                        items: [
                            {

                                xtype: 'image',
                                src: 'resources/images/user3.png',
                                height: 100,
                                margin:20

                            },



                            {
                                xtype: 'textfield',
                                name : 'Name',
                                label: 'Name',
                                value :'Kenny Chow',
                                readOnly: true
                            },
                             {
                                xtype: 'textfield',
                                name : 'Age',
                                label: 'Age',
                                value :'20',
                                readOnly: true
                            },
                             {
                                xtype: 'textfield',
                                name : 'Point',
                                label: 'Point Available',
                                 value :'50',
                                 id :'point',
                                 readOnly: true
                            },
                             {
                                xtype: 'textfield',
                                name : 'lastVisited',
                                label: 'Last Visited',
                                id :'lastVisited',
                                value :'27/12/2012 11:53 AM',
                                readOnly: true
                            },


                            {
                                 xtype:'button',
                                 text: 'Scan',
                                 width : '100%',
                                 id: 'btnScan',

                            },




                        ]

                    }
                ]

            },


            {
                 flex: 2,
                 xtype :'carousel',
                  cls :'containerRadious' ,

                 items :[
                    {

                         xtype :'keypad',
                           layout: {
                            type: 'hbox',
                              pack: 'center'
                        },
                    },

                    {
                        xtype:'couponlistcard'


                    }


                 ]


            }




        ],


   }

});

控制器

     onbtnAddClick: function (e) {
              var loyaltyform =   Ext.getCmp('loyaltyform'); 
                var pointAvalaible = Ext.getCmp('point').getValue();
                var keyPadValue = Ext.getCmp('keypad_value').getValue();
                var consumerID = Ext.getCmp('keypad_value').getValue();
          Ext.getCmp('loyaltyform').setTitle('Changed Title');; 

}

但我得到这个错误。

**Uncaught TypeError: Object [object Object] has no method 'setTitle'** 

以前有人遇到过这个问题吗?请帮忙

4

1 回答 1

0

您收到错误的原因是因为 formpanel 没有方法setTitle()。要更改标题,您必须调用您的方法,该setTitle()方法fieldset位于您的窗体面板中。所以给你 fieldset 一个 ID 并使用它:

Ext.getCmp('yourFieldsetID').setTitle('Changed Title');

在 Sencha 文档中检查可用于面板和字段集的方法:

http://docs.sencha.com/touch/2-1/#!/api/Ext.form.Panel

http://docs.sencha.com/touch/2-1/#!/api/Ext.form.FieldSet

祝你好运!

于 2013-02-18T08:47:52.090 回答