Javascript Xtemplate语句允许匹配字符串吗?
我有这个问题,我需要知道是否有可能对XTemplate内的参数进行字符串比较操作。我需要知道字符串中是否有子字符串。 这是我的密码。我需要一份声明来检查“L”是否为RIV_FiltroJavascript Xtemplate语句允许匹配字符串吗?,javascript,extjs,string-comparison,Javascript,Extjs,String Comparison,我有这个问题,我需要知道是否有可能对XTemplate内的参数进行字符串比较操作。我需要知道字符串中是否有子字符串。 这是我的密码。我需要一份声明来检查“L”是否为RIV_Filtro var detailRivenditoreTemplate = new Ext.XTemplate( '<tpl for="rivenditori">', '<div id="boxDettaglioRivenditori">', '<h1&g
var detailRivenditoreTemplate = new Ext.XTemplate(
'<tpl for="rivenditori">',
'<div id="boxDettaglioRivenditori">',
'<h1>{RIV_RagioneSociale}</h1>',
'<div>',
'{RIV_Indirizzo}',
'<p>{RIV_CAP} - {RIV_Localita}, {RIV_Regione}</p>',
'{RIV_Paese}',
'</div>',
'</div>',
'</tpl>'
);
var detailRivenditoreTemplate=new Ext.XTemplate(
'',
'',
“{RIV_RagioneSociale}”,
'',
“{RIV_Indirizzo}”,
“{RIV_CAP}-{RIV_Localita},{RIV_Regione}”,
“{RIV_Paese}”,
'',
'',
''
);
我想这是不可能的,但我只是问是否有人已经面对了这个问题。
提前感谢您可以使用如下模板功能:
var detailRivenditoreTemplate = new Ext.XTemplate(
'<tpl for="rivenditori">',
'<div id="boxDettaglioRivenditori">',
'<h1>{RIV_RagioneSociale}</h1>',
'<div>',
'<tpl if="[this.checkFilter(RIV_Filtro)] > -1">{RIV_Indirizzo}</tpl>',
'<p>{RIV_CAP} - {RIV_Localita}, {RIV_Regione}</p>',
'{RIV_Paese}',
'</div>',
'</div>',
'</tpl>', {
checkFilter: function(filter) {
return filter.indexOf("L");
}
}
);
var detailRivenditoreTemplate=new Ext.XTemplate(
'',
'',
“{RIV_RagioneSociale}”,
'',
“{RIV_Indirizzo}”,
“{RIV_CAP}-{RIV_Localita},{RIV_Regione}”,
“{RIV_Paese}”,
'',
'',
'', {
检查过滤器:功能(过滤器){
返回过滤器。indexOf(“L”);
}
}
);
这是一把小提琴:
在本例中,仅当RIV_Filtro包含“L”时,才会显示RIV_Indirizzo。您是指{RIV_Filtro}字段的内容吗?因为你可以在XTemplate中使用if操作符。是的,
{RIV_Filtro}
的内容。如果{RIV_Filtro}
是“LC”,我怎么知道“L”是否是{RIV_Filtro}
的子字符串?我已经发布了一个示例