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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:19:11+00:00 2026-06-01T21:19:11+00:00

I have the following data: var data = [ { id: 1, name: ‘Ed

  • 0

I have the following data:

var data = [
    {
        id: 1,
        name: 'Ed Spencer',
        phoneNumber: '555 1234',
        children: [{
          id: 11,
          name: 'Baz'
        }]
    },
    {
        id: 2,
        name: 'Abe Elias',
        phoneNumber: '666 1234',
        children: [{
          id: 21,
          name: 'Foo'
        },{
          id: 21,
          name: 'Bar'
        }]
    }
];

Is there a way to load it into some models and a store, like this?

Ext.define('Child', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'id',    type: 'int'},
        {name: 'user_id',    type: 'int'},
        {name: 'name',  type: 'string'}
    ],

    belongsTo: 'User'
});

Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'id',    type: 'int'},
        {name: 'name',  type: 'string'},
        {name: 'phone', type: 'string', mapping: 'phoneNumber'}
    ],

    hasMany: {model: 'Child', name: 'children'}
});

var store = Ext.create('Ext.data.Store', {
    autoLoad: true,
    model: 'User',
    data : data
});

I have only found one way to do this so far, by looping over the store:

store.each(function(r){
  r.childrens().loadData(r.data.children);
});

But this doesn’t seem great.

I only want to load the data once. I don’t really want to specify the foreign key in each child, as my data is already structured.

Has anyone done something similar? Is there a better way to approach this?

  • 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-01T21:19:14+00:00Added an answer on June 1, 2026 at 9:19 pm

    Think I have fixed it. Apparently you need use a reader in your store, even if its just a memory one, like this:

    var store = Ext.create('Ext.data.Store', {
        autoLoad: true,
        model: 'User',
        data : data,
        proxy: {
            type: 'memory',
            reader: {
                type: 'json'
            }
        }
    });
    

    Then it will populate all models, generating its associations without the need for foreign keys.

    I’m assuming that without a proxy, the data is loaded in a different way, which does not populate my models.

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

Sidebar

Related Questions

I have the following: somefile.php $(document).ready(function() { var handler = function(data) { var JsDiv
I have the following data test<-data.frame(group=1:10, var.a=rnorm(n=10,mean=500,sd=20), var.b=runif(10)) I would like a barplot with
I have the following linq expression pulling all data from my database: var items
when handling data, i always have to write the following: var dataSourceRequest:URLRequest = new
In my .js file I have the following data structure var menu = {
I have an extremely simple JSON object that looks like the following: var data
Given the following data structure var things = [{ name: thing1, sex: male}, {
I have the following JS $('#Submit').click(function () { var name = $('#Name').val(); var age
I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I have the following HTML (..) <tbody> <tr> <td class=name> Test1 </td> <td class=data>

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.