Results 1 to 3 of 3

Thread: Passing Data from Parent to child

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: Passing Data from Parent to child

    Hello, I'm trying to do something as simple as passing the Data from a parent to a child so the child can show the info that the parent has, I'm doing it but nothing happens and I only see an empty page.

    This method calls the view, don't freak out about the code, I'm just practicing with this...

    Code:
    tapLevel2Button: function(button, e, options) {
            var movie1 = Ext.create('App.model.Movie', {
                image: './1.png',
                answer : 'raro 2',
                resolved: 'false',
            });
    
    
            var movie2 = Ext.create('App.model.Movie', {
                image: './2.jpeg',
                answer : 'raro 2',
                resolved: 'false',
            });
    
    
            var movie3 = Ext.create('App.model.Movie', {
                image: './3.jpeg',
                answer : 'raro 2',
                resolved: 'false',
            });
    
    
            var movie4 = Ext.create('App.model.Movie', {
                image: './4.jpeg',
                answer : 'raro 2',
                resolved: 'false',
            });
    
    
            this.getMainNavigation().push({
                xtype: 'moviescarousel',
                title: 'Level 2',
                data: [            
                    movie1.data,
                    movie2.data,
                    movie3.data,
                    movie4.data,
                ],
            });
        },
    Inside the Carousel I have an item that is a DataView which I can't pass the data directly, I've tryed things like:
    Code:
    store: {
        fields: ['image'],
        data: this.getData(),
        itemTpl: '<div>{image}</div>',
    },
    or

    Code:
    store: {
        fields: ['image'],
        data: this.data,
        itemTpl: '<div>{image}</div>',
    },
    but neither of them actually worked. So I decided to do it when the page is activated, like this:


    Code:
    Ext.define('App.view.MoviesCarousel', {
        extend: 'Ext.carousel.Carousel',
        xtype: 'moviescarousel',
    
    
        requires: [
        'Ext.dataview.DataView',
        ],
    
    
        config: {
            styleHtmlContent: true,
            
            items: [
            {
                xtype: 'dataview',
                name: 'moviedataview',
                store: {
                    fields: ['image'],
                    itemTpl: '<div>{image}</div>',
                },
            },
            ],
    
    
            listeners: {
                activate : 'inicializar'
            },
        },
    
    
        inicializar : function() {
            var movieDataView = Ext.ComponentQuery.query('dataview[name=moviedataview]')[0];
            var datos = this.getData();
            movieDataView.getStore().setData(datos);
            movieDataView.refresh();
        }
    });
    Can anybody help me? How is this supposed to be done?

    By the way, I'm trying to do something like this: http://stackoverflow.com/questions/8312571/image-gallery-using-sencha-touch

    I
    s it so hard?

  2. I have never tried having images in a store, just text. But the itemTpl: has always gone outside of the store: not inside.
    example:
    store: {
    fields: ['img'],
    data: [ {img: image.jpg}, {img: image2.jpg}, {img: image3.jpg} ]
    },
    itemTpl: {img}

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    15
    Answers
    1
    Vote Rating
    0
      0  

    Default

    I have never tried having images in a store, just text. But the itemTpl: has always gone outside of the store: not inside.
    example:
    store: {
    fields: ['img'],
    data: [ {img: image.jpg}, {img: image2.jpg}, {img: image3.jpg} ]
    },
    itemTpl: {img}

  4. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Thank you so much! It was so easy. I'm sorry my mistake!
    I'm not trying to set images in the store, they are just the path to them...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •