1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    21
    Vote Rating
    0
    Answers
    2
    whisher is on a distinguished road

      0  

    Default Answered: MVC add click event on the icon add form the controller

    Answered: MVC add click event on the icon add form the controller


    Hi,
    PHP Code:
    Ext.define('SA.view.user.List' ,{
        
    extend'Ext.grid.Panel',
        
    alias 'widget.userlist',
        
    title 'All Users',
        
    store'Users',
        
    initComponent: function() {
           
            
    this.columns = [
                {
                    
    header'Id',
                    
    sortabletrue,
                    
    dataIndex'id',
                    
    flex1,
                    
    field: {
                        
    type'textfield'
                    
    }
                },
                {
                    
    header'Name',
                    
    sortabletrue,
                    
    dataIndex'uname',
                    
    flex1,
                    
    field: {
                        
    type'textfield'
                    
    }
                },
                {
                    
    header'Email',
                    
    sortabletrue,
                    
    dataIndex'email',
                    
    flex1,
                    
    field: {
                        
    type'textfield'
                    
    }
                }
            ];

            
    this.callParent(arguments);
        },

        
    dockedItems: [
            {
                    
    xtype'toolbar',
                    
    items: [{
                        
    iconCls'icon-add',
                        
    text'Add',
                        
    scopethis
                       
                    
    }, {
                        
    iconCls'icon-delete',
                        
    text'Delete',
                        
    disabledtrue,
                        
    itemId'delete',
                        
    scopethis
                       
                    
    }]
                },
            {
                
    xtype'pagingtoolbar',
                
    store'Users',   // same store GridPanel is using
                
    dock'bottom',
                
    displayInfotrue
            
    }
        ]
    }); 
    I've added a simple add delete toolbar to my grid but how
    I can add an event listener to my controller - controll for
    the add button ?

    PHP Code:
    init: function() {
            
    this.control({
                
    'userlist': {
                    
    itemdblclickthis.editUser
                
    },
                
    'userlist > toolbar/*my attempt but it doesnt work :( */': {
                    
    clickthis.insertUser
                
    },
                
    'useredit button[action=save]': {
                    
    clickthis.updateUser
                
    }
            });
        }, 

  2. I've added an id
    PHP Code:
    items: [{
                        
    iconCls'icon-add',
                        
    id'b-add',
                        
    text'Add',
                        
    scopethis
                       
                    

    and than simply

    PHP Code:
    'userlist > toolbar > button#b-add': {
                    
    clickthis.insertUser
                

    Thanks the same

  3. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    21
    Vote Rating
    0
    Answers
    2
    whisher is on a distinguished road

      0  

    Default


    I've added an id
    PHP Code:
    items: [{
                        
    iconCls'icon-add',
                        
    id'b-add',
                        
    text'Add',
                        
    scopethis
                       
                    

    and than simply

    PHP Code:
    'userlist > toolbar > button#b-add': {
                    
    clickthis.insertUser
                

    Thanks the same