Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:37:52+00:00 2026-06-02T04:37:52+00:00

Say the input data is a json like: { facet_fields:{ cat:[ electronics,3, card,2, graphics,2,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:37:53+00:00Added an answer on June 2, 2026 at 4:37 am

    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 cat field into better data that the tpl can understand.

    Ext.define('MyModel', {
        extend: 'Ext.data.Model',
    
        config: {
            fields: [
                {
                    name: 'cat',
                    convert: function(values, record) {
                        var data = [],
                            ln = values.length,
                            i, name, value;
    
                        // loop through each of the array values
                        for (i = 0; i < ln; i++) {
                            // if it is a name, save it
                            if (i % 2 == 0) {
                                name = values[i];
                            }
    
                            // if it is a value, save the value and push 
                            // to the data array
                            if (i % 2 == 1) {
                                value = values[i];
    
                                data.push({
                                    name: name,
                                    value: value
                                });
                            }
                        }
    
                        // return the data array for this field
                        return data;
                    }
                },
                ...
            ]
        }
    });
    

    And then you can use it in your tpl like this:

    tpl: [
        '<tpl for="cat">',
            '{name}: {value}, '
        '</tpl>'
    ].join()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

say I have input data like so: firstName | lastName | Country Bob |
Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
Lets say that input from the user is a decimal number, ex. 5. 2155
If I am creating say a input field through MXML , I can set
if a user types in an input say 3 into a text box three
Ok say you have this: <input id=test value= /> Value of that input is
Say there is a method Operation , public ObjectOut Operation(ObjectIn input) What is the
Let's say that I expect a list of items from the standard input which
Say I have the following mark up: <label for=name>Name:</label> <input type=radio name=name id=name/> The
Given a Range of numbers say 1 to 10,000, Input is in random order.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.