啊,基本的错误,这是你的代码:
<tpl if="val == 0">
,这是它应该是什么,而不是:::
<tpl if="val === 0">
**注意三个“等于”,你需要你实际上比较两个值之间增加的迹象。所以,如果你通常在模板中写道
x=y
那么这将是
x==y // (you basically add an extra equal)
所以像
x==y //when you're checking if the values are equal
条件语句变为
x===y
编辑::添加整行的编码填充指定的背景颜色
注::请制作单独的XTemplate对象,而不是内联tpl代码。这将使您充分利用XTemplate的全部潜力,包括令人难以置信的酷炫会员功能!
试验1 ::
TPL代码添加背景颜色
'<li class="{[this.listClasses(xindex,xcount)]}">',
'<b> {nameOfMeeting}</b>',
'<br> Start Time : {start} || End Time : {end}',
'</li>',
{
listClasses : function(position, size){
var classes = [];
if (position%2===0) {classes.push("even")}
else {classes.push("odd")};
if (position === 1) {classes.push("first")}
else {classes.push("last")};
return classes.join(" ");
}
}
//注:我已经在我使用改变助手功能添加班级的背景颜色。我的tpl基本上在每个列表行上使用了替代颜色。因此,如果第一行是绿色,第二行是黄色,第三行是绿色,第四行是黄色,依此类推。
相关CSS添加(在标签里选择的listClasses)
#meetingsList li.odd { background-color: #ebdde2; }
#meetingsList li.even { background-color: #fdeef4; }
#meetingsList li.odd { border-bottom: 1px solid #999; }
#meetingsList li.even { border-bottom-style: none; }
编辑试用2添加::新的CSS
CSS
.testview .x-dataview-item { border-bottom : 1px solid #cccbcb; }
.testview .x-item-selected { background-color: #006bb6; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #50b7ff), color-stop(2%, #0080da), color-stop(100%, #005692)); background-image: -webkit-linear-gradient(#50b7ff, #0080da 2%, #005692);
background-image: linear-gradient(#50b7ff, #0080da 2%, #005692);
color: #fff;;
text-shadow: rgba(0, 0, 0, 0.5) 0 -0.08em 0;
border-color: #103656; }
要将CSS添加到代码中,请将以下内容添加到列表对象中::
{
xtype : 'list'
. . . .
cls : 'testview'
}
您的代码应该工作,我认为,如果你的数据是这样的:'[{VAL:1,名称: '名1'} ...]' – ZenMaster