1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    4
    Vote Rating
    0
    groophug is on a distinguished road

      0  

    Default passing data and how to access it correctly

    passing data and how to access it correctly


    Hello all, any help for a nubee greatly appreciated.

    I am passing data successfully to a view via the following code:

    Code:
    ...
    itemtap: function (list, index, target, record) {
    ...
      Ext.Viewport.animateActiveItem (
        {xtype: 'page_videoplayer', data: record.data},
        {type:'pop'}
      );
    }

    I am able to access that data partially in a tpl using the initialize function, however i would like to access that data inside of the 'video' xtype as well in order to set the 'url' and 'posterUrl' correctly. See the commented sections for where i am accessing the data that was passed to the following panel:


    Code:
    
    Ext.define('myapp.view.panel_VideoPlayer', {
    	extend: 'Ext.Panel',
    	xtype: 'page_videoplayer',
    	
    	requires: [
    		'Ext.Video'
    	],
    	// I CAN APPLY THE DATA SUCCESSFULLY TO TPL BELOW USING THIS FUNCTION
    	initialize:function (){
    				var panels = this.query('panel[tpl]'),
    				pLen = panels.length,
    				p = 0,
    				panel;
    				for (p=0; p < pLen; p++) {
    					panel = panels[p];
    					panel.setData(this.getData());
    			    }
    	},
    	
    	layout: {
    		type: 'vbox'
    	},
    	
    	config: {
    		title: 'VideoPlayer',
    		cls: 'bluePanel',
    		scrollable: true,
    		styleHtmlContent: true,
    		
    		items: [
    			{
    				items:[
    					{
    		                xtype: 'video',
    						itemId: 'vplayer',
    						title: 'video player',
    						width: '100%',
    						height: 200,
    						listeners: {
    							activate: function(){
    								// HOW WOULD I CORRECTLY ACCESS THE DATA HERE? THIS OBVIOUSLY NOT CORRECT
    								this.setUrl('http://myurl/'+record.getData('videofile'));
    								this.setPosterUrl('http://myurl/'+record.getData('videothumb'));
    							}
    						}
    		        	}
    				]
    			},
    			{
    		        xtype:'panel',
    				tpl:[
    				// VIA THE INITIALIZE FUNCTION ABOVE I AM ABLE TO ACCESS THE DATA SUCCESSFULLY HERE
    				'Title: {videotitle}</br>',
    				'User: {username}</br>',
    				'Rating: {videorating}</br>',
    				'Views: {videoviews}',
    				'',
    				''
    				].join(''),
    				flex:1
    			}
    		]
    	}
    });

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    The Netherlands
    Posts
    75
    Vote Rating
    4
    SebasSP is on a distinguished road

      0  

    Default


    Code:
    this.up('page_videoplayer').getData()

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    4
    Vote Rating
    0
    groophug is on a distinguished road

      0  

    Default


    SebasSP — sincere thanks for your reply — can you show me exactly how you would apply this?

    I tried your suggestion as follows:
    Code:
    xtype: 'video',
    						itemId: 'vplayer',
    						title: 'video player',
    						width: '100%',
    						height: 200,
    						enableControls: true,
    						listeners: {
    							activate: function(){
    								var videoFile = this.up('page_videoplayer').getData('videofile');
    								this.setUrl('http://myurl.com/'+videoFile+'.m4v');
    								this.setPosterUrl('http://myurl.com/'+videoFile+'png');
    							}
    but i get the following error in the console:
    TypeError: 'undefined' is not an object (evaluating 'this.up('page_videoplayer').getData')

Thread Participants: 1