PDA

View Full Version : Putting an xtype in an itempTpl



colworx
18 Aug 2011, 5:57 PM
Hi, I have a shopping cart in a List, and I want each item to have a selectfield in it as opposed to using plain old <select>.

I would like to be able to define an xtype inside the XTemplate, like this:


itemTpl: new Ext.XTemplate(
'<tpl if="id == 0">',
'<h1>Total</h1>',
'</tpl>',


'<tpl if="id &gt; 0">',
'<div class="cart-product-wrap">',
'<img class="orderitem-delete" src="/m/resources/images/delete.png" alt="" />',
'<span class="cart-qty">',
'<label for="cart-qty-{id}">QTY: </label>',
{
xtype: 'selectfield',
name: 'qty',
id: 'qty',
options: [
{text: '1', value: '1'},
{text: '2', value: '2'}
]
},
'</span>',
'<span class="orderitem-text">{text}</span>',
'<span class="orderitem-price">${price}</span>',
'</div>',
'</tpl>'
),


Does anyone know how to do this, or another way of achieving my goal?

Thanks.

Mthor
22 Aug 2011, 11:50 AM
this might lead you in the right direction

http://www.sencha.com/forum/showthread.php?114317-Button-In-a-Template