extjs无法处理条件语句

extjs无法处理条件语句,extjs,panel,toolbar,Extjs,Panel,Toolbar,我有一个extjs选项卡面板和一个工具栏定义如下 tbar : { { xtype:'box', tpl:[ '<table><tr><td>', '<b>Total Prelim Shares:</b> ', '</td><tpl if="totalPrelimShares < 0" ><td width="30" style = "color:red">', '{totalPrelimSha

我有一个extjs
选项卡面板
和一个
工具栏
定义如下

tbar : {
{
xtype:'box',
tpl:[
'<table><tr><td>',
'<b>Total Prelim Shares:</b> ',
'</td><tpl if="totalPrelimShares < 0" ><td width="30" style = "color:red">',
'{totalPrelimShares}',
'</td></tpl><td width="10">',
'<span class="xtb-sep"></span>',
'</td><td>',
'<b>Total Prelim Gross Amount:</b>',
'</td><td width="70">',
'{totalPrelimGrossAmount}',
'</td><td>',
'<b>Total Prelim Net Amount:</b>',
'</td><td width="70">',
'{totalPrelimNetAmount}',
'</td></tr><table>'             

],
ref:'../ipTotalBar',
data:{totalPrelimShares :'0'}
}
}

没有错误,但不会显示
{totalPrelimShares}
。当我删除
tpl if=“totalPrelimShares<0”>
时,它工作正常。

您遇到的问题可能是因为
XTemplate
不知道什么是
totalPrelimShares
。在中的示例中,每当使用传递到模板配置中的变量时(如您的示例中的
totalPrelimShares
),总是使用
this.*
。例如:

<tpl if="this.totalPrelimShares < 0">

一定是

<tpl if="totalPrelimShares &lt; 0" >


必须分别作为实体
编写(如果在条件中使用)。此文档有误。

您使用的是>;或者<,还要确保将模板定义为Ext.XTemplate。我想默认的可能是Ext.Template
<tpl if="{[totalPrelimShares]} < 0">
<tpl if="totalPrelimShares < 0" >
<tpl if="totalPrelimShares &lt; 0" >