PDA

View Full Version : Problem of updateing record information to Video container



00999p
15 Oct 2013, 1:48 AM
Hi

I am learning Touch framework and I encounter a problem where Google can't answer me .

My app has a container for playing html5 video. When the user taps one row of Ext.dataview.List, the app will fire a event and activate the videoPanel.

My question is, how can the videoPanel knows which row has been tapped?

Many examples use videoPanel.setRecord() function to load the values of model instance to fields whose name match those of the model's fields. It works for the component such as textfield, but how can I use it to update the video.url property?



Ext.define("video.model.VideoModel", { extend : "Ext.data.Model",
config : {
idProperty : 'id',
fields : [ {
name : 'id',
type : 'int'
}, {
name : 'title',
type : 'string'
}, {
name : 'url',
type : 'string'
} ]
}
});


Ext.define('video.view.VideoPanel', { extend : "Ext.Container",
alias : "widget.videopanel",


initialize : function() {
this.callParent(arguments);
var backButton = {
xtype : "button",
ui : "back",
text : "Home",
handler : this.onBackButtonTap,
scope : this
};


var topToolbar = {
xtype : "toolbar",
docked : "top",
name : '{title}',
items : [ backButton, {
xtype : "spacer"
} ]
};


var video = {
xtype : 'video',
url : '{url}',
posterUrl : "http://b.vimeocdn.com/ts/261/062/261062119_640.jpg"
};


this.add( [ topToolbar, video ]);
},


setRecord : function(record) {
console.log(record);
this.callParent(arguments);

},


onBackButtonTap : function() {
this.fireEvent("backMainCommand", this);
}


});

controller:


...
activateVideoPanel : function(record) {
var videoPanel = this.getVideoPanel();
videoPanel.setRecord(record);
Ext.Viewport.animateActiveItem(videoPanel, this.slideLeftTransition);
},
...

fmoseley
16 Oct 2013, 5:15 PM
You can get a reference to the dataview and call getSelection to get the selected record.
http://docs.sencha.com/touch/2.3.0/#!/api/Ext.mixin.Selectable-method-getSelection

fmoseley
16 Oct 2013, 9:18 PM
Or you could pass the data as a parameter when you fire the event.
http://docs.sencha.com/touch/2.3.0/#!/api/Ext.mixin.Observable-method-fireEvent