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 8655567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:03:49+00:00 2026-06-12T15:03:49+00:00

How to change the code so that combobox shows the list of ​​displayField values

  • 0

How to change the code so that combobox shows the list of ​​displayField values when store has nested json data.

When I edit column “name” by combobox, it shows empty list.

Ext.define("Model", {
    extend: "Ext.data.Model",
    fields: [
        {name: "id", type: "int"},
        {name: "name.name"},
        {name: "phone", mapping: "name.phone"},
        {name: "descr", type: "string", mapping:'description'}
    ]
});

// store with data that we will recieve from test echo ajax service
var Store = Ext.create("Ext.data.Store", {
    model: "Model",
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: '/echo/json/',
        actionMethods: {read: 'POST'}, // echo ajax service required
        extraParams: {
            json: Ext.JSON.encode({
                root: [{id: 1, name: {name:"John", phone: "123"}, description:"Fapfapfap"},
                       {id: 2, name: {name:"Danny", phone: "234"}, description:"Boobooboo"},
                       {id: 3, name: {name:"Tom", phone: "345"}, description:"Tralala"},
                       {id: 4, name: {name:"Jane", phone: "456"}, description:"Ololo"},]
                })
        },
        reader: {
            type: 'json',
            root: 'root'
        }
    },
});

// and finally I have a grid panel
Ext.create("Ext.grid.Panel", {
    store: Store,
    columns: [
        {dataIndex: "id", header:"ID"},
        {dataIndex: "name.name", header:"Name", flex: 1, editor: {xtype:"combo", store: Store, displayField:'name.name'}},
        {dataIndex: "phone", header:"Phone", flex: 1, editor: "textfield"},
        {dataIndex: "descr", header: "Description", flex: 2, editor: "htmleditor"}
    ],
    //selType: 'rowmodel',
    plugins: [Ext.create('Ext.grid.plugin.CellEditing')],
    renderTo: Ext.getBody(),
});

Example here: http://jsfiddle.net/3MknG/2/

  • 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-12T15:03:50+00:00Added an answer on June 12, 2026 at 3:03 pm

    It works as intended if I set field ‘name’ mapping as below.

    {name: "name", mapping: "name.name"}
    

    And configure the grid column like this:

    {dataIndex: "name", header:"Name", flex: 1, 
     editor: {xtype:"combo", store: Store, displayField:'name'}},
    

    Changed example is here: http://jsfiddle.net/3MknG/3/

    But I don’t want to change the name of field ‘name.name’ to ‘name’ because it works as intended for grid.

    Has anyone encountered a similar problem?

    UPDATE:

    I have found one solution. Not the best but it works for me.

    I add new field with mapping configuration dynamically to store model when combo is init as component.

    Ext.define("MyCombo", {
        extend: "Ext.form.field.ComboBox",
        alias:"widget.mycombo",
        initComponent: function(){
            var me = this;
    
            if (me.displayMapping) {
                var store = me.getStore();
                var proxy = store.getProxy();
                var model = proxy.getModel();
                me.displayField = Ext.id(me.displayMapping); // It is necessary to have difference between the name and other existing names in model.
                // Add new field with mapping to store model
                model.prototype.fields.add(new Ext.data.Field({ name: me.displayField,
                                                                mapping: me.displayMapping}));
            }
            me.callParent();
        }
    });
    
    Ext.create("Ext.grid.Panel", {
        store: Ext.create("MyStore"),
        columns: [
            {dataIndex: "id", header:"ID"},
            {dataIndex: "name.name", header:"Name", flex: 1, 
                        editor: {xtype: "mycombo",
                                 store: Ext.create("MyStore"),         
                                 displayMapping: "name.name"}},
            {dataIndex: "phone", header:"Phone", flex: 1, editor: "textfield"},
            {dataIndex: "descr", header: "Description", flex: 2, editor: "htmleditor"}
        ],
        plugins: [Ext.create('Ext.grid.plugin.CellEditing')],
        renderTo: Ext.getBody(),
    });
    

    Changed example you can find here: http://jsfiddle.net/3MknG/7/

    Does anyone know better solution?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code for retrieve the data into combobox. How to change
I have some code that will change the background color of a specific label
I have code that needs to loop and it will need to change the
I have the following code that when i change the drop down it doesnt
I have the following code that i am trying to change from a regular
I have the following SQL code that runs against a Change Request database. Each
How do I change this bit of code so that I only allow pdf
I found this great code snippet that works wonderfully during circumstances that change a
How do I change the following bit of code so that I only have
I'm using .net. Is there some code somewhere that can change $11,456.50 -> eleven

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.