1. #1
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    157
    Vote Rating
    2
    tomdchi is on a distinguished road

      0  

    Default How to listen to select even in controller

    How to listen to select even in controller


    In SA I have the grid:

    Code:
    Ext.define('MyDesktop.view.client.ClientReturns', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.clientReturns',
    
        height: 250,
        itemId: 'clientReturns',
        width: 632,
        title: 'Client Returns',
        forceFit: true,
        store: 'client.ClientReturnsStore',
    
        initComponent: function() {
            var me = this;
    
            Ext.applyIf(me, {
                columns: [
                    {
                        xtype: 'gridcolumn',
                        hidden: true,
                        dataIndex: 'id',
                        text: 'ID'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'juris_name',
                        text: 'Jurisdiction'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'return_name',
                        text: 'Return Name'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'state',
                        text: 'State'
                    }
                ],
                viewConfig: {
                    itemId: 'clientReturnsGridView'
                },
                dockedItems: [
                    {
                        xtype: 'pagingtoolbar',
                        dock: 'bottom',
                        width: 360,
                        displayInfo: true,
                        store: 'client.ClientReturnsStore',
                        items: [
                            {
                                xtype: 'searchfield',
                                store: 'client.ClientReturnsStore',
                                margins: '0 0 0 5',
                                width: 200
                            }
                        ]
                    }
                ],
                selModel: Ext.create('Ext.selection.RowModel', {
    
                })
            });
    
            me.callParent(arguments);
        }
    
    });
    And the controller:
    Code:
    Ext.define('MyDesktop.controller.client.ClientReturns', {
        extend: 'Ext.app.Controller',
    
        models: [
            'client.ClientReturnsModel'
        ],
        stores: [
            'client.ClientReturnsStore'
        ],
        views: [
            'client.ClientManagement',
            'client.ClientReturns'
        ],
    
        refs: [
            {
                ref: 'clientManagement',
                selector: 'clientManagement'
            },
            {
                ref: 'clientReturns',
                selector: 'clientReturns'
            },
            {
                ref: 'clientReturnsGridView',
                selector: '#clientReturnsGridView'
            }
        ],
    
        onRowModelSelect: function(rowmodel, record, index, eOpts) {
    
        }
    
    });
    onRowModelSelect was converted to an action in SA but the control is missing. Can someone help me spot whats missing here?

  2. #2
    Sencha - Architect Dev Team
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    886
    Vote Rating
    32
    jminnick has a spectacular aura about jminnick has a spectacular aura about

      0  

    Default


    Are you just trying to listen for a select event on a grid row? If so, give your grid an itemId and add the following bit of code to the init function in your controller:

    Code:
    this.control({
        "grid[itemId=clientReturnsGrid]" : {
            select: this.onRowModelSelect
        }
    })
    Jason Minnick
    Sencha Architect Development Team

Thread Participants: 1