Results 1 to 5 of 5

Thread: Override List behaviour, Tap event

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Location
    Bangalore India
    Posts
    6
    Vote Rating
    0
      0  

    Default Answered: Override List behaviour, Tap event

    I want to override the behavior of a List. Normally ,on tap of a listitem, the listitem gets selected/deselected. I basically do not want this to happen on a tap, but i want the selection/deslection to happen ONLY on a 'itemtaphold'.

    Is there anyway i can override the selection/deseletion of item on itemtaphold instad of item tap. I am not well versed in Sencha. Any code snippit which will help me achieve would be appriciated.


    Code:
    Ext.create('Ext.List', {
        fullscreen: true,
        itemTpl: '{title}',
        allowDeselect :true,
        data: [
            { title: 'Item 1' },
            { title: 'Item 2' },
            { title: 'Item 3' },
            { title: 'Item 4' }
        ]
    });

  2. There is a config called triggerEvent that is inherited from DataViews. You can use this config to change what event fires the select event.
    Code:
    triggerEvent: 'itemtaphold',
    Here is a demo.

  3. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    101
      0  

    Default

    You can stop the itemtap event from firing and listen for the itemtaphold event. The code would look something like this:
    Code:
    Ext.create('Ext.List', {
        fullscreen: true,
        itemTpl: '{title}',
        data: [
            { title: 'Item 1' },
            { title: 'Item 2' },
            { title: 'Item 3' },
            { title: 'Item 4' }
        ],
        listeners: {
            itemtap: function(list, index, target, record, event){
                event.stopEvent();
            },
            itemtaphold: function(list, index, target, record){
                 Ext.Msg.alert('itemtaphold event<br> fired at index: ' + index);
            }
        }
    });
    Here is a demo.

  4. #3
    Sencha User
    Join Date
    Dec 2012
    Location
    Bangalore India
    Posts
    6
    Vote Rating
    0
      0  

    Default

    Hi Jerome,

    Thank you for the reply.

    The problem here is when there is a single tap, the item still gets selected. I dont want this to happen. If i use disableSelection = true. Selection of the list item wont happen at all (Either itemtap or itemtaphold). I need selection to happen only on ItemTaphold.

  5. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,149
    Answers
    132
    Vote Rating
    101
      0  

    Default

    There is a config called triggerEvent that is inherited from DataViews. You can use this config to change what event fires the select event.
    Code:
    triggerEvent: 'itemtaphold',
    Here is a demo.

  6. #5
    Sencha User
    Join Date
    Dec 2012
    Location
    Bangalore India
    Posts
    6
    Vote Rating
    0
      0  

    Default

    Thanks Jerome. That works. Exactly what i was looking for. I dint realise this configuration was there.

Tags for this Thread

Posting Permissions

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