【问题标题】:Sencha Touch 1.1 Lists, Store, "animating" store updates in the view (fade/blink in)Sencha Touch 1.1 列表、存储、在视图中“动画化”存储更新(淡入/闪烁)
【发布时间】:2012-02-08 12:23:55
【问题描述】:

当我使用 storeObj.insert(modelObj) 更新商店时,列表面板会自行更新,因为它应该。但是,我希望看到新添加的项目“动画”出现在视图中。有没有办法做到这一点?

【问题讨论】:

    标签: sencha-touch extjs


    【解决方案1】:

    在您的模型中,有一个名为 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>',
    

    【讨论】:

    • 后续问题:我以前从未做过 dummystore,这将如何运作?
    • 没有什么比得上 dummystore .... dummy store 我的意思是使用临时存储来复制原始存储并将其所有模型实例标记为不是新的...然后把所有这些“不是新的”回到原始存储中的实例以及稍后插入的实例,其 newItem 值为 1。您是如何尝试 itemTpl 的……效果好吗?
    猜你喜欢
    • 1970-01-01
    • 2015-12-26
    • 2011-12-24
    • 2012-02-10
    • 1970-01-01
    • 2011-10-07
    • 2012-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多