-
8 Jan 2013 8:15 AM #1
Unanswered: Change Style and width of DataItem dynamically
Unanswered: Change Style and width of DataItem dynamically
Hi,
i've got a problem concerning the dataView and dataItem components. In the below scribble, you can see my intention.
dataview.PNG
The left figure should be shown in portrait mode and the right one in landscape mode. I've manually managed it by setting
for the landscape mode.Code:width: '50%', style: 'float:left'
But how to register an "orientationchange" event for the dataItem components to set them dynamically on orientation change?
-
8 Jan 2013 9:10 AM #2
Try something like this. You're going to have to test it as that's off the top of my head.:
Code:// Assign the event lsitener Ext.Viewport.on('orientationchange', function(){ var orientation = Ext.Viewport.getOrientation(), dataView = Ext.ComponentQuery.query('...dataview selector...')[0]; if (orientation == 'landscape'){ dataView.setWidth('50%'); dataView.setStyle({ 'float':'left' }); } else { // The other stuff } }, this);
-
9 Jan 2013 1:09 AM #3
Hey george,
thx for your hint. I finally got it with this code fragment:
Code://... var orientation = Ext.Viewport.getOrientation(), dataItems = Ext.ComponentQuery.query('.hostlistitem'), i; if (orientation == 'landscape') { for(i=0;i<dataItems.length;i++) { dataItems[i].setWidth('50%'); dataItems[i].setStyle('float:left'); } } else { for(i=0;i<dataItems.length;i++) { dataItems[i].setWidth('100%'); dataItems[i].setStyle('float:none'); } } //...


Reply With Quote