1. #1
    Sencha User
    Join Date
    May 2010
    Location
    Belgium
    Posts
    214
    Vote Rating
    1
    Answers
    4
    marxan is on a distinguished road

      0  

    Default Unanswered: How te get data from DB with toolbar?

    Unanswered: How te get data from DB with toolbar?


    Hello,

    I'm trying to create a menu by using the toolbar menu but in the example, the data are filled with the 'text' option. I would like to make it work with data from my DB as I won't need to come back in the code if a new option should appear.

    My second question is a bit more complex, I don't know how to interact with another part of my screen when I click on the selected item. I've tried to create a Handler with a simple alert but nothing happened.

    Code:
    Ext.define('TAB.view.MainBorder', {    extend: 'Ext.panel.Panel',
        alias:'widget.mainborder',
        layout: 'fit',
        initComponent: function() {
            var me = this;
            Ext.applyIf(me,{
    
    
                items: [
                	{ 	xtype: 'panel',
                		dockedItems: [{
                		dock: 'top',
                		xtype: 'toolbar',
                		height: 40,
                		xtype: 'button',
        				text: 'Choose indicator group',
    				    menu: {
         					plain: true,
    					    showSeparator: false,
    					    items: [{
          								text: 'menu item one',
          								scope: this,
          								handler: this.onAddClick
         							},
         							{
    							      text: 'menu item two'    
    							    },
    							    {
    							      text: 'menu item three'    
    							    }]
        						},
            
            onAddClick: function(){
           			alert('test');
       		 }
        
                		
    
    
                	}]
                	}
                ],
                
         //              
        })
         me.callParent(arguments);
        }
        
    
    
    });
    Thanks in advanced for any help.

    Regards,

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    Oklahoma, USA
    Posts
    52
    Vote Rating
    8
    Answers
    10
    sdt6585 will become famous soon enough

      0  

    Default


    I think your scope for the event handling function is wrong, try this:

    Code:
    Ext.define('TAB.view.MainBorder', {    extend: 'Ext.panel.Panel',
        alias:'widget.mainborder',
        layout: 'fit',
        onAddClick: function(){
            alert('test');
        },
        initComponent: function() {
            var me = this;
            Ext.applyIf(me,{
                items: [{
                    xtype: 'panel',
                    dockedItems: [{
                        dock: 'top',
                        xtype: 'toolbar',
                        height: 40,
                        xtype: 'button',
                        text: 'Choose indicator group',
                        menu: {
                            plain: true,
                            showSeparator: false,
                            items: [
                                {
                                    text: 'menu item one',
                                    scope: this,
                                    handler: this.onAddClick
                                },
                                {
                                    text: 'menu item two'
                                },
                                {
                                    text: 'menu item three'
                                }
                            ]
                        }
                    }]
                }]
            });
    
    
            me.callParent(arguments);
        }
    });
    Last edited by sdt6585; 18 Jun 2012 at 9:03 AM. Reason: messed up the formatting big time

  3. #3
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    Answers
    690
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You may want to have a look at this:
    http://www.sencha.com/forum/showthread.php?132422

    Scott.

  4. #4
    Sencha User
    Join Date
    May 2010
    Location
    Belgium
    Posts
    214
    Vote Rating
    1
    Answers
    4
    marxan is on a distinguished road

      0  

    Default


    Thanks, it works.

Thread Participants: 2