简体   繁体   中英

Sencha Touch 2.4, highlighting new record in the list

I would like to highlight new record(s), let say all new news(s) and unread from last 3 days to be highlighted as new in the list and when user clicks on the record and read the detail, change to unhighlighted.

my json, delivers delivers the date and time of the each recored.

any idea how to manage this issue?

you have to use itemTpl property of the Ext.dataview.DataView class, see config: itemTpl Basically this is an expression of Ext.XTemplate

In your case imagine you defined in model field unread , then you can write something like:

 config: {
        itemTpl: [
            '<div',
            '<tpl if="unread"> class="my-unread-css"</tpl>',
            '>',
            '{newsText}',
            '<div>',
        ]
 }

Then somewhere in controller call of the function will remove css class from the list item.

 function markAsRead(newsModel) {
      newsModel.set('unread', false);
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM