1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    54
    Vote Rating
    2
    geniodella is on a distinguished road

      1  

    Default nested data into xtemplate dataview example using extjs 4.0.7 with MVC

    nested data into xtemplate dataview example using extjs 4.0.7 with MVC


    Hi Guys,
    i was finally able to use nested data in xtemplate dataview overriding three functions
    of the abstractview in the version 4.0.7 of extjs taking the implementation
    from the release candidate 4.1 and the implementation of the update indexes
    from a forum in internet because the one on the RC is not perfect.



    Code:
    Ext.Loader.setConfig({enabled: true});
    
    
    Ext.override(Ext.view.AbstractView, {
        prepareData: function(data, index, record) {
           var associatedData, attr;
            if (record) {
                associatedData = record.getAssociatedData();
                for (attr in associatedData) {
                    if (associatedData.hasOwnProperty(attr)) {
                        data[attr] = associatedData[attr];
                    }
                }
            }
            return data;
        }
    });
    
    
    Ext.override(Ext.view.AbstractView, {
        collectData : function(records, startIndex){
            var data = [],
                i = 0,
                len = records.length,
                record;
    
            for (; i < len; i++) {
                record = records[i];
                data[i] = this.prepareData(record.data, startIndex + i, record);
            }
            return data;
        },
    
        // private
        bufferRender : function(records, index){
            var me = this,
                div = me.renderBuffer || (me.renderBuffer = document.createElement('div'));
    
            me.tpl.overwrite(div, me.collectData(records, index));
            
            return Ext.query(me.getItemSelector(), div);
        }
    });
    
    
    Ext.override(Ext.view.AbstractView, {
       // private
         updateIndexes : function(startIndex, endIndex) {
            var ns = this.all.elements,
                records = this.store.getRange();
            startIndex = startIndex || 0;
            endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
            for(var i = startIndex; i <= endIndex; i++){
                ns[i].viewIndex = i;
                ns[i].viewRecordId = ((records.length > i) && records[i]) ? records[i].internalId : undefined;
                if (!ns[i].boundView) {
                    ns[i].boundView = this.id;
                }
            }
        }
    });
    Last edited by mitchellsimoens; 21 Mar 2012 at 6:41 AM. Reason: added [CODE] tags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,677
    Vote Rating
    749
    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


    Why didn't you use one Ext.override instead of 3?
    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
    Join Date
    Oct 2011
    Posts
    54
    Vote Rating
    2
    geniodella is on a distinguished road

      0  

    Default


    I am not fond with javascript
    i am making my first moves with extjs that's why
    i used 3 overrides......

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Posts
    84
    Vote Rating
    0
    suamikim is on a distinguished road

      0  

    Default


    Thanks for the code. This is exactly what I was just looking for. Unfortunately the dataview does not update correctly after manipulating the store (deleting, updating records, ...).

    Do you have any idea how this could be solved?

    Maybe you can have a look at this thread I just started where i describe the problem a little more in detail.

    Thanks & best regards,

    Mike

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar