Search code examples
sencha-touch-2titleformpanel

Change form panel title sencha touch


I need to change my title inside a formpanel

Here is my code

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'


                    }


                 ]


            }




        ],


   }

});

Controller

     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');; 

}

but i get this error.

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

Anyone face this problem before? please help


Solution

  • The reason you get the error is because a formpanel has no method setTitle(). To change the title you have to call the setTitle() method of your fieldset, which is inside your formpanel. So give you fieldset an ID and use this:

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

    Check the methods you can use for a panel en fieldset in the Sencha docs:

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

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

    Good luck!