RSS

Add icons to NestedList in Sencha Touch

29 Apr

NestedList with icons

Unlike most other components NestedLists is missing itemTpl property.

According to Sencha documentation we should use the method called getItemTextTpl instead.

The quick example. Assuming your store looks something like this:

var eventsListStore = new Ext.data.TreeStore({
    model: 'EventItem',
    root: {
        items: [
            {leaf: true, eventName: 'Event 1', eventImage: 'http://url to image'},
            {leaf: true, eventName: 'Event 2', eventImage: 'http://url to image 2'},
            ...
       ]
    },
    proxy: {
        type: 'ajax',
        reader: {
            type: 'tree',
            root: 'items'
        }
    }
});

Then NestedList configuration would be:

...
store: eventsListStore,
getItemTextTpl: function() {
    return '<img class="eventIcon" src="{eventImage}"> {eventName}';
}
...
Advertisements
 
2 Comments

Posted by on April 29, 2011 in misc

 

2 responses to “Add icons to NestedList in Sencha Touch

  1. steffbo

    July 28, 2011 at 3:16 pm

    nice, really helped me!

     
    • Dasha Salo

      July 28, 2011 at 3:27 pm

      I am glad 🙂

       

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: