sencha touch改变特定列表项的颜色

neo*_*ser 5 javascript list sencha-touch

有一个非常基本的列表组件,但想要改变某些行的行颜色取决于一个值/我尝试设置一个tpl但它似乎没有工作.任何帮助,将不胜感激

Ext.create('Ext.dataview.List', {
    id : 'mylist',
    store: myStore,
    tpl: new Ext.XTemplate(
             '<tpl for=".">'
             '    <tpl if="val == 0"><div style="background-color:red">{name}</div></tpl>',
             '    <tpl if="val == 1"><div>{name}</div></tpl>',
             '</tpl>'
    )
});
Run Code Online (Sandbox Code Playgroud)

sta*_*229 0

这就是我所做的:

items: [{
    xtype: 'list',
    id: 'patientList',
    store: app.stores.patientList,
    itemTpl: new Ext.XTemplate('<tpl if="overDue14Days &gt; 0"><div class="severeItem"></div></tpl><tpl if="overDue3Days &gt; 0"><div class="mildItem"></div></tpl>', '<div class="listBox">', '<div class="listText">{patientFirstName} {patientLastName}', '<div class="metadata">{numberOfOrders} orders</div>', '</div>', '<div class="listSpacer"></div>', '<div class="deleteItem" id="notMyPatientButton"></div>', '<div class="listArrow"></div>', '</div>'),
Run Code Online (Sandbox Code Playgroud)

在我的 css 中,我使用背景渐变而不是背景颜色:

    .severeItem {
    background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0%,#fccdce), color-stop(10%, #fcc2c4), color-stop(50%,#fdaaac), color-stop(100%, #ff8891));
}

    .mildItem{ 
        background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0%,#feedba), color-stop(10%, #fcda8b), color-stop(50%,#fdd986), color-stop(100%, #ffe888));
    }
Run Code Online (Sandbox Code Playgroud)