开发者

Creating Action Sheet in Sencha Touch when a list item is `tapped`

I have a List generated from JSON data in Sencha Touch. Essentially, the list is generated from a Data Store object and acts as a Contacts list. I would like to know how to add functionality so that when the user taps on one of the list items, an Action Sheet is shown in Sencha Touch, offering a number of ac开发者_JAVA百科tions (such as 'Call', 'Send Message' and 'Delete').

Here's the code I'm using to generate the ListvIew:

var listView = new Ext.List({
    store: friendStore,
    itemTpl: '{forename} {surname}<br />{phoneNumber}',
    grouped: true,
    indexBar: true
});

I know that I could possibly use the on parameter, but that will append the tap event to the List, rather than each item. The displayed action sheet will contain some links as well with the tel:// so it needs to be dynamic as well (since the telephone number to call is also stored in the Data Store under the key {phoneNumber}

Hope that makes sense...


ListView has an itemtap event you should listen for. From the docs:

itemtap : ( Ext.DataView view, Number index, Ext.Element item, Ext.EventObject e )

To get the record that corresponds to the tapped item just do view.getStore().getAt(index). Then in your event handler just recreate the ActionSheet based on the data from the record and show it.

Also attaching the listener to the list is more memory efficient than attaching to each individual item.


This isn't a great answer but I would look at the DataView, which is a parent of List.

It has a property called itemSelector which you may be able to use to specify a subsection of your list entry. If you use the itemSelector you also have to provide a tpl property as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜