extjs - Sencha Touch change itemTpl on specific items in list -


i'd able add class in itemtpl item has it's field "answered" set "true" sound's easy me, don't know start..

i know have check if answered true in tpl, don't know how write in template.. o.o

        //model     ext.define('user', {         extend: 'ext.data.model',         config: {             idproperty: 'name',             fields: [                 {name: 'name', type: 'string'},                 {name: 'address', type: 'string'},                 {name: 'id', type: 'int'},                 {name: 'weburl', type: 'string'},                 {name: 'infourl', type: 'string'},                 {name: 'answered', type: 'boolean'},                 ]         }     });      //store      astore = ext.create('ext.data.store', {         model: 'user',         sorters: 'name',         grouper: {             groupfn: function(record) {                 return record.get('name')[0];             }         }     });      //full store      store = ext.create('ext.data.store', {         model: 'user',         sorters: 'name',         grouper: {             groupfn: function(record) {                 return record.get('name')[0];             }         },         proxy: {             type: 'ajax',             url: '/services/restaurantlist.ashx',             reader: {                 type: 'json',                 rootproperty: 'users'             }         },         listeners:{             load: function(){                 var = store.data.all;                 astore.setdata(all.slice(0,30));             }         },         autoload: true     });       //the list     list = ext.create('ext.list', {         flex: 8,         itemtpl: ['<div class="contact">{name}</div>'],         store: astore,         listeners: {             itemtap: function(list, index, target, record) {                 maincontainer.setactiveitem(1);                 detailspanel.setrecord(record);         },         plugins: [             {                 xclass: 'ext.plugin.pullrefreshfn',                 refreshfn: function(){                     store.cleardata();                     astore.cleardata();                     store.clearfilter();                     astore.clearfilter();                     store.load();                     list.refresh();                 }             }         ],         grouped: true     }); 

have looked @ docs xtemplate? http://docs.sencha.com/touch/2.2.1/#!/api/ext.xtemplate. in particular, @ "conditional processing basic comparison operators" section.

if don't want use <tpl if=""> notation, can use ternary operator:

itemtpl: new ext.xtemplate(     '<div class="{[values.answered ? \'answered\' : \'\']}">{name}</div>' ), ... 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -