Sencha Touch 二 - Dataview里面实现items迭代并初始化items的一些属性

本文介绍如何在Sencha Touch 2中使用DataItem进行迭代并初始化控件属性,解决itemTpl仅支持HTML标签的问题,通过定义自定义组件CartItem实现控件的动态加载。
Sencha Touch 2 - Dataview 里面实现items迭代并 初始化items的 一些属性

前提条件:ST2有很多items放到container里面需要用着模版使用。 items很多属性需要初始化并且赋值。当然itemTpl可以实现迭代。但是有个缺点是只能使用html标签。不能使用ST的一些控件标签。所以本文将介绍怎么使用dataitem方式迭代初始化控件。


item的模版,也就是模版的迭代部分



/**
 * @author larrywoo Email:larrywoo1982@gmail.com
 */
Ext.define('DingCan.view.CartItem', {
extend : 'Ext.Container',
xtype : 'mydataview',
requires : ['Ext.Label'],

config : {
//scrollable : true,

//fullscreen : true,
layout : 'vbox',


items : [{
xtype : 'container',
layout : 'hbox',
items : [{
//id : 'image',
itemId : 'cartimage',
xtype : 'image',
mode : 'tag',
src : '',
cls : 'cart-item-thumb'
},

{
xtype : 'container',
flex : 1,


layout : 'vbox',
items : [{
itemId : 'name',
//id : 'name',
html : '产品名称',
cls : 'cart-item-name'
}, {
xtype : 'container',
cls : 'cart-item-props',


layout : 'vbox',
items : [{
itemId : 'price',
//id : 'price',
html : '价格:¥4.00',
cls : 'item-prop'
}, {
itemId : 'taste',
//id : 'taste',
html : '麻辣,少蒜少葱',
cls : 'item-prop'
}]
}]
}


…………………………………………………………………………

本文固定链接:http://www.verydemo.com/demo_c113_i4055.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值