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
    Gainesville, FL
    Posts
    37,207
    Answers
    3517
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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
    ________________
    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 in print!

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

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    9
    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,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      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.