さまざまな JSON データ フィールドを組み合わせて ListItem コンテンツをカスタマイズする方法を知りたいと思っていました。
{caption}、{subCaption}、{source} の 3 つの JSON フィールドがあります。
これまでのところ、dataMap を使用し、カスタム クラスを使用して追加のテキストとスタイルをそれぞれにラップすることができました。ただし、コンテンツを追加できる唯一の方法は、適用/更新機能を使用して順次追加することです。その結果、私の ListItems は単純に {caption},{subCaption},{source} という行になっています。
各 ListItem を次のように表示する方法は次のとおりです。
- {caption} と {subCaption} のテキストを組み合わせて短いストーリーを作成し、これをパネルとして ListItem に追加します
- 手順 1 で作成したパネルの右下にドッキングされた小さなパネルに {source} をレンダリングします。
どうすれば上記を行うことができますか?抽出された質問は次のようになります: さまざまな JSON フィールドのデータにアクセスして結合し、ListItem にレンダリングするにはどうすればよいですか?
ListItem の現在のコードを参照用に以下にコピーします。
いつものように、どんな助けも大歓迎です! ありがとう!
ムハンマド
カリフォルニア州サンノゼ
Ext.define('qxtapp.view.ResultsListItem', {
extend: 'Ext.dataview.component.ListItem',
requires: [
'qxtapp.view.ResultsListItemCaption'
],
xtype : 'resultslistitem',
alias : 'widget.resultslistitem',
config: {
caption: true,
subCaption: true,
source: true,
dataMap: {
getCaption: {
setHtml: 'caption'
},
getSubCaption: {
setHtml: 'subCaption'
},
getSource: {
setHtml: 'source'
}
},
layout: {
type: 'vbox'
}
},
applyCaption: function(config) {
return Ext.factory(config, qxtapp.view.ResultsListItemCaption, this.getCaption());
},
updateCaption: function(newCaption) {
if (newCaption) {
this.add(newCaption);
}
},
applySubCaption: function(config) {
return Ext.factory(config, Ext.Component, this.getSubCaption());
},
updateSubCaption: function(newSubCaption) {
if (newSubCaption) {
this.add(newSubCaption);
}
},
applySource: function(config) {
return Ext.factory(config, Ext.Component, this.getSource());
},
updateSource: function(newSource) {
if (newSource) {
this.add(newSource);
}
}
});
Ext.define('qxtapp.view.ResultsListItemCaption', {
extend: 'Ext.Component',
applyHtml: function(caption) {
// do some customization to caption and return it
return caption;
}
});