Hi. I have a method in my controller that gets relative paths from a php file and then takes the resulting list and creates image components for them. When the method fires it adds all of the images in as expected, but at the end i have a .doLayout() method call to have the layout recalculate but it doesn't work.
I've tried adding in the doLayout at all of the points in the process, even in my loops to create the enclosing containers, and it doesn't work. Once the method is done and the page is built I can manually resize the browser window and all of the images snap to the sizes they should be.
I've also tried using the method .doComponentLayout() and I've tried hiding the parent container and showing it after the child components are all added and neither of these worked either.
Can anyone offer up any help? My method looks like this:
Code:
getPhotos: function (){
var photoStore = this.getPhotosStore();
photoStore.proxy.extraParams = {};
photoStore.proxy.extraParams.callMethod = "getThumbs";
var photoContainer = this.getPhotoContainer();
photoStore.removeAll();
photoStore.load({
callback: function (records, operation, success){
for (var ct = 0; ct < records.length; ct+=4){
// group these into containers of four buttons
var row = Ext.create("Ext.container.Container",{
layout:{type: 'hbox', pack: 'center'},
})
// we have to add the items like this b/c if there is no record (if there's not a number of images evenly divisible by four) we'll get an error
for (var innerLoopCt = 0; innerLoopCt < 4; innerLoopCt++ ){
if ( ct + innerLoopCt < records.length){
row.add(Ext.create("Ext.Img",{src: records[ct + innerLoopCt].data.thumbPath}));
}
}
photoContainer.add(row);
}
photoContainer.doLayout();
}
});
},
and the view file that it's being rendered to looks like this:
Code:
Ext.define('CaRWedding.view.content.Photos',{
extend: 'Ext.container.Container',
xtype: 'photos',
id: 'photosPanel',
cls: 'background',
autoScroll: true,
layout: {type: 'hbox', pack: 'center'},
config:{
layout: 'vbox',
defaults: {flex:1},
items: [
{
xtype : 'container',
layout : {type: 'vbox', pack: 'center'},
defaults : {flex: 1},
id : 'photoContainer' // this is the container that the controller's photoContainer ref creates the getPhotoContainer method for
}
]
}
});