PDA

View Full Version : changing scroll direction on orientation change



Frances
16 Feb 2011, 2:59 PM
Hi all, I have two templates for a dataview depending on the orientation. Portrait layout needs to scroll vertically and the landscape layout, horizontally. It works fine in either orientation when the application is first loaded, but the scroll direction doesn't update dynamically (the template does). Code sample below:



var mostViewed = new Ext.DataView({
title: 'Most Viewed',
store: storeTabViewed,
tpl: Ext.getOrientation() == "portrait" ? templates.tabbedViewTplPortrait : templates.tabbedViewTplLandscape,
scroll: Ext.getOrientation() == "portrait" ? 'vertical' : 'horizontal',
itemSelector: 'li.menu-item',
fullscreen: false,
monitorOrientation: true,
layoutOrientation: function(orientation, w, h) {
if (orientation == 'portrait') {
this.tpl = templates.tabbedViewTplPortrait
this.scroll = 'vertical'
this.refresh()
}
}
}
})

I've tried using "this.setScrollable('vertical')" in the layoutOrientation function above but that doesn't scroll anything.

Not sure what I'm doing wrong so any clues much appreciated.

Cheers