たとえば、店舗に次のものがあるとします。
{
"document": {
"success": "true",
"totalAllocation": "40000000.00",
"fundAllocation": [
{
"fundName": "Zais Opportunity Ltd Class B",
"allocation": "10000000.00"
},
{
"fundName": "Metacapital Mortgage Opportunities Ltd",
"allocation": "10000000.00"
},
...
]
}
}
そして、私がやりたいことは次のようなものです:
itemTpl: Ext.create('Ext.XTemplate',
'<div>',
'<span>{fundName}</span>',
'<span>{[this.getPercentage(values.allocation, parent.totalAllocation)]}%</span>',
'</div>',
{
getPercentage: function (allocation, totalAllocation) {
return Ext.Number.toFixed(allocation / totalAllocation, 2);
}
}
)
しかし、もちろん、このスコープの「親」が空であるため、これは機能しません。
XTemplate の Fundtion 内の totalAllocation フィールドの値を取得して、現在のファンドに割り当てられたパーセンテージをリスト項目に表示する方法はありますか? 回避策も大歓迎です。