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

  • Home
  • SEARCH
  • 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 8408017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:31:45+00:00 2026-06-09T23:31:45+00:00

I’m using Ext 4.1. I have some issues with loading json data with associations.

  • 0

I’m using Ext 4.1. I have some issues with loading json data with associations. The flat data gets loaded perfectly, only the ‘hasMany’ doesn’t work. (if loaded there nowhere to be found). If a record is loaded I want to be able to get the 2 stores of Attendee’s and the 1 store of documents.

I can also change the JSON format to a better format (if you have suggestions let me know!)

I have this json data.

This is my first model:

Ext.define('App.model.package.LabVisit', {
    extend: 'Ext.data.Model',
    requires: [
        'App.model.package.Attendee',
        'App.model.package.Document'
    ],
    idProperty: 'labVisitID',

    fields: [
        {
            mapping: 'lab_visit_id',
            name: 'labVisitID',
            type: 'int'
        },
        {
            mapping: 'lab_id',
            name: 'labID',
            type: 'int'
        },
        ... some more irrelevant...
        {
            mapping: 'comments',
            name: 'comments'
        },
        {
            name: 'upddate'
        }
    ],
    hasMany: [
        /* edit: added foreignKey (also tried with: lab_visit_id) */
        { model: 'package.Attendee', name: 'attendeeLabList', associationKey:'attendee_lab', foreignKey: 'labVisitId' },
        { model: 'package.Attendee', name: 'attendeeEmpList', associationKey:'attendee_emp', foreignKey: 'labVisitId' }
        { model: 'package.Document', name: 'document', associationKey:'document' },
    ]

});

I have following attendee model:

Ext.define('App.model.package.Attendee', {
    extend: 'Ext.data.Model',

    fields: [
        /* edit: added this field */
        {
            mapping: 'lab_visit_id',
            name: 'labVisitId'
        },
        {
            mapping: 'attendee_id',
            name: 'AttendeeID'
        },
        {
            mapping: 'first_name',
            name: 'firstName'
        },
        {
            mapping: 'last_name',
            name: 'lastName'
        },
        {
            name: 'email'
        }
    ]
});

following document model:

Ext.define('App.model.package.Document', {
    extend: 'Ext.data.Model',

    fields: [
        {
            mapping: 'document_id',
            name: 'docID'
        },
        {
            mapping: 'document_name',
            name: 'docName'
        },
        {
            mapping: 'document_mimetype',
            name: 'mimeType'
        },
        {
            name: 'uploadID'
        }
    ]
});

Finally my store:

Ext.define('App.store.package.LabVisit', {
    extend: 'Ext.data.JsonStore',
    requires: [
        'App.model.package.LabVisit'
    ],

    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};

        me.callParent([Ext.merge({
            storeId: 'labVisitStore',
            model: 'App.model.package.LabVisit',
            remoteSort: true,
            proxy: {
                type: 'ajax',
                api: {
                    read: API_URLS.getVisitList //url to the json
                },
                reader: {
                    type: 'json',
                    root: 'rows'
                }
            }
        }, cfg)]);
    }
});

Edit:
I’ve added the foreign key in the model and added it to the hasMany

Still no difference. This is my output:

the first record in the store

I also find it a strange: If it’s broken I expect an exception. And there are 2 mysterious stores always present but I don’t have a clue why or what’s the purpose.

  • 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-09T23:31:46+00:00Added an answer on June 9, 2026 at 11:31 pm

    The problem was in this part:

    hasMany: [
        { model: 'package.Attendee', name: 'attendeeLabList', associationKey:'attendee_lab' },
        { model: 'package.Attendee', name: 'attendeeEmpList', associationKey:'attendee_emp' },
        { model: 'package.Document', name: 'document', associationKey:'document' },
    ]
    

    @Izhaki helped me a lot. Thanx! Especially with the fiddle. I started there and begun with switching the code with my code piece by piece. Until I saw the model was the problem.

    models should be defined like this: App.model.package.Attendee

    I think it’s sad that the framework doesn’t show a significant error/warning if a model isn’t recognised/doesn’t excist/isn’t supplied… But meh, it works now.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.