extjs 无法处理条件语句
我有一个像这样定义的 extjs tabpanel
和 toolbar
。
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'}
}
}
我这样称呼它:
var obj = {totalPrelimShares : -10,totalPrelimNetAmount:20,totalPrelimGrossAmount : 30 };
this.ipTotalBar.update(obj);
没有错误,但 {totalPrelimShares}
未显示。当我删除 tpl if="totalPrelimShares < 0" >
时,它工作正常。
I have a extjs tabpanel
and a toolbar
defined like this.
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'}
}
}
I call it like this:
var obj = {totalPrelimShares : -10,totalPrelimNetAmount:20,totalPrelimGrossAmount : 30 };
this.ipTotalBar.update(obj);
No errors, but the {totalPrelimShares}
does not show up. When I remove the tpl if="totalPrelimShares < 0" >
, it works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您遇到的问题可能是因为
XTemplate
不知道totalPrelimShares
是什么。在XTemplate 文档
,每当使用传递到模板配置中的变量(如您的情况下的
totalPrelimShares
),它总是使用this.*
来引用。例如:如果这不起作用,您还可以尝试使用文档中定义的内联运算符
{[ ... ]}
:The problem that you're experiencing may be because the
XTemplate
does not know whattotalPrelimShares
is. In the examples in theXTemplate
documentation, whenever using a variable passed into the template configuration (liketotalPrelimShares
, in your case), it is always referred to usingthis.*
. For example:If that doesn't work, you can also try using the inline operators
{[ ... ]}
as defined in the documentation:必须是
<
、>
和"
必须写为实体<
、如果在条件语句中使用,则分别为 >
和"
文档对此有误。must be
<
,>
and"
must be written as entities<
,>
and"
respectively if used within the conditional. The documentation is wrong on this one.