Reputation: 366
I have a list item that is populated by a store. Once the store loads, the list does not seem to resize with the proper height. The height is in fact zero. Do you guys have any recommendations on having the list re-calculate its height after loading the store?
My view:
xtype: 'fieldset',
cls: 'damage-list-fieldset',
margin: '',
itemId: 'damageFieldSet',
flex: 1,
layout: {
type: 'fit'
},
items: [
{
xtype: 'list',
action: 'showNotes',
cls: 'damage-list',
itemCls: 'x-list-item-label',
itemId: 'DamageList',
disableSelection: true,
height: 'auto',
emptyText: 'No damage has been reported',
itemTpl: [
'<table border="0" width="100%">',
' <tr>',
' <td class="part" width="30%">{part}</td>',
' <td class="note" width="30%">{date}</td>',
' <td class="type" width="30%">{type}</td>',
' <td class="note" width="10%"><div class="count">{noteCount}</div></td>',
' </tr>',
'</table>',
''
],
store: 'Damage',
grouped: true,
onItemDisclosure: false
}
]
},
I realize the itemTpl shouldn't have tables in it, but let's ignore that for now.
Here's how I'm currently forcing it to work. I push the height from the controller store load callback.
Ext.getStore('Damage').load({
params: {repairOrderId: this.repairOrderId},
callback: function(records, operation, success) {
if(records.length) {
report.getComponent('noteInstruction').setHidden(records.length == 0);
/* Calculate the height of the damage rows and set it*/
var location = new Array();
var locationCount = 0;
for(var i = 0; i < records.length; i++) {
if(location.indexOf(records[i].data.location) < 0) {
location.push(records[i].data.location);
locationCount++;
}
}
var damageRow = 54;
var damageHeader = 56;
var damageHeight = (records.length * damageRow) + (locationCount * damageHeader);
report.getComponent('damageFieldSet').getComponent('DamageList').setHeight(damageHeight);
report.getComponent('damageFieldSet').getComponent('DamageList').setScrollable(false);
}
Ext.Viewport.setMasked(false);
},
scope: this
});
Not very elegant, because I'm just jamming in a set height.
So the question is, how do I force the list to redraw its height after getting the records back from the store?
Upvotes: 1
Views: 1166
Reputation: 5054
The loading process is async and your callback from the load does not neccessarily affect the list.
I would recommend, that you
And last but not least you can use on the list config:
variableHeights: true
Upvotes: 1