Sencha touch 在XTemplate Sencha Touch 2中插入按钮

Sencha touch 在XTemplate Sencha Touch 2中插入按钮,sencha-touch,extjs,sencha-touch-2,Sencha Touch,Extjs,Sencha Touch 2,我正在使用framwork Sencha Touch 2,现在我在创建列表组件时遇到问题,因为我为此创建了一个XTemplate,但我需要在列表的每个元素中插入一个按钮组件 { xtype: 'list', id: 'list_product', emptyText: '<div class="list-empty-text">No hay coincidencias</div>',

我正在使用framwork Sencha Touch 2,现在我在创建列表组件时遇到问题,因为我为此创建了一个XTemplate,但我需要在列表的每个元素中插入一个按钮组件

        {
            xtype: 'list',
            id: 'list_product',
            emptyText: '<div class="list-empty-text">No hay coincidencias</div>',
            store: 'Product',
            itemTpl: Ext.create('Ext.XTemplate',
                '<h3>{name}</h3>' +
                '[{xtype:"button"}]'//Here i tried insert a button
            ),
            items: [
                {
                    xtype: 'toolbar',
                    docked: 'top',
                    items: [
                        {xtype: 'spacer'},
                        {
                            xtype: 'searchfield',
                            placeHolder: 'Buscar...'
                        },
                        {xtype: 'spacer'}
                    ]
                }
            ]
        }
{
xtype:'列表',
id:“列出产品”,
emptyText:“无任何意外”,
商店:“产品”,
itemTpl:Ext.create('Ext.XTemplate',
“{name}”+
“[{xtype:”按钮“}]”//我在这里尝试插入一个按钮
),
项目:[
{
xtype:'工具栏',
停靠:“顶部”,
项目:[
{xtype:'间隔'},
{
xtype:“搜索字段”,
占位符:“公共汽车…”
},
{xtype:'间隔'}
]
}
]
}

我阅读了文档,但没有看到示例或一些代码帮助。

您不能以这种方式使用
itemTpl
XTemplate
。模板是用HTML编写的,而在
XTemplate

'<h3>{name}</h3>' + //This is HTML
'[{xtype:"button"}]' //This is Javascript
{name}+//这是HTML
“[{xtype:”按钮“}]”//这是Javascript

为了完成您想要的操作,您需要使用
dataview
dataitem
。有关如何使用它们的示例,请参考Dataview和

使用Dataview,我可以创建一个搜索器组件,如列表组件中所示?可能是这样。查看如何为
列表执行此操作<代码>列表
数据视图
的子类。如果您需要更多详细信息,您应该创建另一个问题。