Results 1 to 3 of 3

Thread: How to add event listeners to components from controller and how to call data.json

  1. #1
    Sencha Premium User
    Join Date
    Feb 2015
    Posts
    60
    Answers
    2

    Default Answered: How to add event listeners to components from controller and how to call data.json

    The code is in the below url. In app/controller/Home.js Controller file, I created store to get checkboxes data from "data/data1.json" (In method "getLeftNav") but the store is not returning any values where did I do mistake.

    https://fiddle.sencha.com/#fiddle/o9n

    In ur project we have our own architecture which is built on ExtJs where we have a config section event inside which we can add event listeners to components defined in view. In Pure ExtJs 4.2.2 how to add listeners in controller. (Assume I need change event to be triggered on combo box defined in app/view/Home.js). Combo box code

    Code:
    {
                            xtype: 'radiogroup',
                            id: 'filterRadioGroup',
                            border: false,
                            columns: 1,
                            padding: '10 0 0 0',
                            defaults: {
                                labelWidth: 280,
                                labelAlign: 'left',
                                minWidth: 280,
                                maxWidth: 280
                            },
                            items: [
                                {
                                    boxLabel: 'Show All',
                                    checked: true,
                                    name: 'filtertype',
                                    inputValue: 'All'
                                }, {
                                    boxLabel: 'My Choice',
                                    name: 'filtertype',
                                    inputValue: 'MyInvest'
                                }
                            ]
                        }

  2. In your controller, you can use the following approaches for controller access:

    Code:
        refs : [
            {
                ref      : 'editPanel',
                selector : 'my-form'
            },
            {
                ref      : 'gridPanel',
                selector : 'my-grid'
            }
    
        ],
    
        init : function () {
            var me = this;
    
            me.control({
                'my-grid' : {
                    selectionchange : me.onSelecChange,
                    ..
                },
    
                // all combos on form
                'my-form combobox' : {
                    beforequery : me.onComboQuery
                },
    
                'my-form button[action=saveChanges]'   : {
                    click : me.onSaveChanges
                }
    
            });
    
            me.listen({
                store: {
                    '#Users' : {
                        beforeload : function(store, operation, eOpts) {
                        },
                    }
                }
            });
    
        }, 
    
        onSelecChange : function () {
            var me = this,
                gridPanel = me.getGridPanel(); // ref getter
        },

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    In your controller, you can use the following approaches for controller access:

    Code:
        refs : [
            {
                ref      : 'editPanel',
                selector : 'my-form'
            },
            {
                ref      : 'gridPanel',
                selector : 'my-grid'
            }
    
        ],
    
        init : function () {
            var me = this;
    
            me.control({
                'my-grid' : {
                    selectionchange : me.onSelecChange,
                    ..
                },
    
                // all combos on form
                'my-form combobox' : {
                    beforequery : me.onComboQuery
                },
    
                'my-form button[action=saveChanges]'   : {
                    click : me.onSaveChanges
                }
    
            });
    
            me.listen({
                store: {
                    '#Users' : {
                        beforeload : function(store, operation, eOpts) {
                        },
                    }
                }
            });
    
        }, 
    
        onSelecChange : function () {
            var me = this,
                gridPanel = me.getGridPanel(); // ref getter
        },

  4. #3
    Sencha Premium User
    Join Date
    Feb 2015
    Posts
    60
    Answers
    2

    Default

    Thanks Scott now I understood it

Similar Threads

  1. Replies: 1
    Last Post: 5 May 2014, 3:44 AM
  2. Replies: 6
    Last Post: 23 Apr 2014, 5:42 AM
  3. Replies: 3
    Last Post: 31 Mar 2014, 6:48 PM
  4. Call store listeners in Controller
    By mrhomer in forum Ext: Q&A
    Replies: 4
    Last Post: 23 May 2012, 5:23 AM
  5. Event listeners on Non-Ext Components
    By rainerh in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 13 Jul 2010, 5:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •