【发布时间】:2012-02-08 12:23:55
【问题描述】:
当我使用 storeObj.insert(modelObj) 更新商店时,列表面板会自行更新,因为它应该。但是,我希望看到新添加的项目“动画”出现在视图中。有没有办法做到这一点?
【问题讨论】:
标签: sencha-touch extjs
当我使用 storeObj.insert(modelObj) 更新商店时,列表面板会自行更新,因为它应该。但是,我希望看到新添加的项目“动画”出现在视图中。有没有办法做到这一点?
【问题讨论】:
标签: sencha-touch extjs
在您的模型中,有一个名为 newItem 的额外字段。所以你的模型将是:
Ext.regModel('Product', {
fields: [
**{name: 'newItem', type: 'boolean'},**
{name: 'name', type: 'string'},
{name: 'description', type: 'string'},
{name: 'price', type: 'float'},
{name: 'image_url', type: 'string'},
{name: 'in_stock', type: 'boolean'}
]
});
当您将商品插入商店时
storeObj.insert(modelObj)
在插入之前您必须有 modelObj.newItem=true。
此外,在插入任何新项目之前,您必须将所有旧项目标记为“NOT NEW”。为此,您可能必须使用 dummystore。
现在使用 EXt.xTemplate,如下所示:(用于您的 Ext.List)
itemTpl: '<tpl for=".">'
+ '<tpl if="newItem==1">'
+ ' <p color="red"> this item is new</p></tpl>'
+ '<tpl else >
+ ' this item is old</tpl>'
+ '</tpl>',
【讨论】: