Say the input data is a json like:
{ "facet_fields":{
"cat":[
"electronics",3,
"card",2,
"graphics",2,
"music",1
]}}
The array “cat” is recovered and should be displayed using a for loop. I’m stuck at this point 🙂
The code so far:
Ext.define('Sandbox.view.FacetList', {
extend: 'Ext.List',
xtype: 'facet-list',
config: {
baseCls: 'article-list',
itemTpl: '' +
'<div class="article">' +
'<tpl for="categories">' +
'<div>Item {#}</div>' +
'</tpl>' +
'</div>'
}
});
This outputs: Item 1 Item 2 Item 3 Item 4
and I’d like to see the following output:
electronics (3), card (2), graphics (2), music (1)
Can’t find the right way.
thanks for your time 🙂
J.
I’m assuming you are using a model and a store for your data? If so, I suggest you use the convert method available in fields. It will allow you to convert that
catfield into better data that thetplcan understand.And then you can use it in your
tpllike this: