我有一个由商店填充的列表项。商店加载后,列表似乎不会以适当的高度调整大小。高度实际上为零。你们有什么建议让列表在加载商店后重新计算它的高度?
我的观点:
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
}
]
},
我意识到 itemTpl 中不应该有表格,但现在让我们忽略它。
这是我目前强迫它工作的方式。我从控制器存储加载回调中推送高度。
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
});
不是很优雅,因为我只是在设定的高度上卡住。
所以问题是,在从商店取回记录后,如何强制列表重新绘制其高度?