1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    30
    Vote Rating
    0
    pm.sreejith is on a distinguished road

      0  

    Question Unanswered: How can we track click event on a list or dataview component?

    Unanswered: How can we track click event on a list or dataview component?


    Hi All,

    How can we track click event on a list or dataview component?. Please go through the code given below and let me know...

    Code:
    Ext.define('Sencha.view.ContentList', {
        extend: 'Ext.DataView',
        requires: ['Sencha.store.Contentlist'],    
        xtype: 'contentlist',
        
        config: {
            width:  350,
            itemTpl: '<div id="{categoryid}" style="width:350px;float:left; padding:8px;border-bottom:1px solid #ccc;"><font size="2">{catogory}</font></div>',
            store: 'Contentlist',
            scrollable: 'vertical',
            scope:this
        },
        
        listeners:{
            el:{
                tap: Ext.Msg.alert("Validate", "You are clicked on Item", function(){}),
                delegate: 'div'
            }
        }        
    });
    I am using ST2.0 with MVC pattern.

    Thanks in advance...

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Code:
    listeners : {
        itemtap: function(dataview, index, item, e) {
            Ext.Msg.alert("Validate", "You are clicked on Item");
        }
    }
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    7
    Vote Rating
    0
    garyb72 is on a distinguished road

      0  

    Default


    Shouldn't the listener be in the controller, not the view?

  4. #4
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,156
    Vote Rating
    4
    Answers
    93
    rdougan is on a distinguished road

      0  

    Default


    In your controller, do something like this in your this.control() method:

    Code:
    this.control({
        'contentlist': {
            'itemtap': this.onItemTap
        }
    });
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

Tags for this Thread