1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    68
    Answers
    3
    Vote Rating
    1
    slngr is on a distinguished road

      0  

    Default Answered: DataView - Question for understanding

    Answered: DataView - Question for understanding


    Hello,

    I have a question about the DataView component in ST. Created it like this:

    Code:
    Ext.define('App.view.HomeDataView', {    extend: 'Ext.DataView',
        xtype: 'home_dataview',
            
        config: {
    
    
            defaults: {
                styleHtmlContent: true
            },
          
            // Store declaration for tile data
            store: 
    			{
    			  fields: ['id', 'name', 'img_url'], 
    			  data: [
    				{id: 'tile1', name: 'Blog', img_url: 'img/thumbnail.png'},
    				{id: 'tile2', name: 'Style Filter', img_url: 'img/thumbnail.png'}
    			  ] 
    			}
    		,
            
    		itemTpl: '<h1>test</h1><h2>{name}</h2>'
        },
    
    
        initialize: function() {
            console.log('>> Home_DATA_VIEW [created]');
    		var data = this.getStore().data.items[0];
    		console.log(data);
            this.callParent();
        },
    });
    Everything works like a charm, but if I comment the following two lines out:

    Code:
    //var data = this.getStore().data.items[0];
    		//console.log(data);
    I get an error like this:

    Code:
    Uncaught TypeError: Object [object Object],[object Object] has no method 'each'
    Why does this happen? Must the DataView initialized? Where should I initialize the DataView in MVC architecture?

    Thank you

  2. it kind of depends on when the store is applied to the dataview. For instance you shouldn't do this:

    Code:
    initialize: function() {
        this.store = Ext.create('Ext.data.Store', {...});
    
        this.callParent(arguments);
    }
    You should use the setStore

    Code:
    initialize: function() {
        this.setStore(Ext.create('Ext.data.Store', {...}));
    
        this.callParent(arguments);
    }

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,795
    Answers
    3467
    Vote Rating
    834
    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


    Looks like this is because the store hasn't translated the data array into a valid Ext.util.MixedCollection yet. I would caution you that you could be sharing the same store for any instance of that class if you define it like that.
    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.

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    68
    Answers
    3
    Vote Rating
    1
    slngr is on a distinguished road

      0  

    Default


    Well is there a better solution or declaration? Sorry my english is not the best and I don't really understand what's wrong here. Want to make a clean DataView in MVC.

    Is my solution the only one possible, or should I change it into another one?

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,795
    Answers
    3467
    Vote Rating
    834
    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


    You can set the store in initialize
    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.

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    68
    Answers
    3
    Vote Rating
    1
    slngr is on a distinguished road

      0  

    Default


    Could you be so kind and give a little code example again? How do I setup the store in the DataView initialize function?

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,795
    Answers
    3467
    Vote Rating
    834
    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


    it kind of depends on when the store is applied to the dataview. For instance you shouldn't do this:

    Code:
    initialize: function() {
        this.store = Ext.create('Ext.data.Store', {...});
    
        this.callParent(arguments);
    }
    You should use the setStore

    Code:
    initialize: function() {
        this.setStore(Ext.create('Ext.data.Store', {...}));
    
        this.callParent(arguments);
    }
    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.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi