Sencha touch Sencha touch itemTpl,不按条件显示行
如果值为'xxx',我不想在itemTpl中显示行 例如:Sencha touch Sencha touch itemTpl,不按条件显示行,sencha-touch,itemtemplate,Sencha Touch,Itemtemplate,如果值为'xxx',我不想在itemTpl中显示行 例如: itemTpl: '{title}', data: [ { title: 'Item 1' }, { title: 'Item 2' }, { title: 'Item 3' }, { title: 'Item 4' } ] 这里,如果title=='Item 2'表示我不应该显示该行。我需要跳过它 如何实现这一点?这取决于您用来显示数据的组件 如果您使用的是一个列表(并且数据存在于一个存储中),您可以
itemTpl: '{title}',
data: [
{ title: 'Item 1' },
{ title: 'Item 2' },
{ title: 'Item 3' },
{ title: 'Item 4' }
]
这里,如果title=='Item 2'表示我不应该显示该行。我需要跳过它
如何实现这一点?这取决于您用来显示数据的组件 如果您使用的是一个列表(并且数据存在于一个存储中),您可以使用它来简单地过滤列表,实际上不显示您的行
如果您正在使用另一个输出原始HTML的组件,则必须在XTemplate中为itemTpl使用条件逻辑。在视图中,进行以下更改:
xtype: 'list',
id: 'myList',
//itemTpl: '{title}',
data: [
{ title: 'Item 1' },
{ title: 'Item 2' },
{ title: 'Item 3' },
{ title: 'Item 4' }
]
在视图的initialize()函数中写入:
var myList = Ext.getCmp('myList');
myList.setItemTpl([
'<tpl if="title!=\'Item 2\'">',
'{title}',
'<tpl else>',
'',
'</tpl>'
]);
var myList=Ext.getCmp('myList');
myList.setItemTpl([
'',
“{title}”,
'',
'',
''
]);
我想,这应该对你有用