1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    47
    Vote Rating
    1
    eddow is on a distinguished road

      0  

    Default Dynamic items (masks) in Views

    Dynamic items (masks) in Views


    Hello,

    I got a problem and needed hours but I could crawl in your code and find what was on - it might be a low-priority bug for you though.

    The problem roughly comes from the fact that the AbstractView component, when populated the first time, stores the number of items in the View once for all and, after, uses that number when it clears to "remove all the items but the X first ones)
    If the added items change (I got this through masking/unmasking), it doesn't remove some generated items and problems begin.

    Here is a test-case (the setTimeout looks a bit worked out but simulate a remote-store loading)
    Code:
    Ext.define('Company', {    extend: 'Ext.data.Model',
        fields: [
           {name: 'company'}
        ],
        idProperty: 'company'
    });
    
    
    Ext.onReady(function(){
        var store = Ext.create('Ext.data.ArrayStore', {
            model: 'Company',
            data: []
        });
        
        var main = Ext.create('Ext.view.View', {
            renderTo: document.body,
            width: 750,
            height: 400,
            border: false,
            store: store,
            itemSelector: "div.thumb-wrap",
            tpl: '<tpl for=".">'+
                    '<div style="margin-bottom: 10px;" class="thumb-wrap">'+
                      '<div>{company}</div>'+
                    '</div>'+
                '</tpl>'
        });
        main.el.mask('yooplaboom');
        setTimeout(function() {
            main.el.unmask();
            store.removeAll();
            store.add({company: 'American International Group, Inc.'});
        }, 200);
    });
    As I said, the problem is in the way of dealing with "external" component in src/view/AbstractView.js line 436
    Code:
    if (me.refreshCounter) {                me.clearViewEl();
                } else {
                    me.fixedNodes = targetEl.dom.childNodes.length;
                    me.refreshCounter = 1;
                }
    
    (So, once refreshCounter is set, it is never unset and clearViewEl uses the fixedNodes value)
    A solution would be to wrap the viewed records in a DIV and just wipe it clean when needed while letting other parts adding and removing items before or after.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,656
    Vote Rating
    904
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Maybe I'm not following what you are saying but I ran your code and inspected the DOM, it all looks correct.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User brainunit's Avatar
    Join Date
    Dec 2009
    Posts
    3
    Vote Rating
    0
    brainunit is on a distinguished road

      0  

    Default


    Mitchell,

    I also experience this issue:
    • mask view before data load
    • load data in the store - AbstractView remembers fixedNodes value, which includes nodes of mask
    • unmask view - nodes of mask are removed
    • remove all items from the store
    • last item remains in the view - because AbstractView doesn't delete fixedNodes
    Best,
    Oleg

Thread Participants: 2