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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:24:18+00:00 2026-05-30T05:24:18+00:00

I’m stuck trying to retrieve data from an associated model store. Allow me to

  • 0

I’m stuck trying to retrieve data from an associated model store. Allow me to give a brief overview of what I am trying to achieve.

I need a List of quizes, and upon tapping on a quiz it will show a List of questions. Upon tapping on a question you will then get the associated multiple choice answers (maybe a dataview with buttons or another List).

In an earlier beta I used a flat tree store to display the quiz but that was limiting in aesthetics and didn’t allow me to sync my data with the api very easily, and thus I am trying to get the associated models working instead. I’ve found similar issues online can’t quite get what I am after.

Here’s the relevant code (in MVC setup). I have 3 associated models:

QuizModel.js:

app.models.QuizModel = Ext.regModel("QuizModel", {
    fields: [
        { name: 'id', type: 'int' },
        { name: 'studentid', type: 'int' },
        { name: 'dateAllocated', type: 'string' },
        { name: 'category', type: 'string' },
    ],

    associations: [
        {type: 'hasMany', model: 'QuestionModel', name: 'questions'},
    ],

    proxy: {
        type: 'rest',
        actionMethods: {create: "POST", read: "POST", update: "PUT", destroy: "DELETE"},
        url: 'http://localhost/bm/core/api/quiz',
        reader: {
            type: 'json',
            root: 'quizes'
        }
    }

});

app.stores.QuizStore = new Ext.data.Store({
    model: "QuizModel",
    storeId: 'quizStore'
});

QuestionModel.js:

app.models.QuestionModel = Ext.regModel("QuestionModel", {
    fields: [
        { name: 'id', type: 'int' },
        { name: 'quizmodel_id', type: 'int'},
        { name: 'prompt', type: 'string' },
        { name: 'level', type: 'int' },
        { name: 'categoty', type: 'string' }
    ],
    associations: [
        {type: 'hasMany', model: 'AnswerModel', name: 'answers'},
        {type: 'belongsTo', model: 'QuizModel'}
    ]

});

AnswerModel.js:

app.models.AnswerModel = Ext.regModel("AnswerModel", {
    fields: [
        { name: 'id', type: 'int' },
        { name: 'questionmodel_id', type: 'int' },
        { name: 'prompt', type: 'string' },
        { name: 'correct', type: 'string' }
    ],
    associations: [
        {type: 'belongsTo', model: 'QuestionModel'}
    ]
});

QuizController.js:

app.controllers.QuizController = new Ext.Controller({
    index: function(options) {
        console.log('home');
    },
    quizTap: function(options){
        var currentQuiz = app.stores.QuizStore.getAt(options.index);
        var questions = currentQuiz.questions().load().getAt(0);

        app.views.questionList.updateWithRecord(questions);
        app.views.viewport.setActiveItem(
            app.views.questionList, options.animation
        );
    }
});

and finally, my rest API response looks something like this:

{
    "status" : true,
    "quizes" : [{ 
            "id" : "1",
            "category" : "Privacy",
            "date_allocated" : "1329363878",
            "questions" : [{ 
                    "id" : "1",
                    "prompt" : "Lorem ipsum dolor sit amet?",
                    "answers" : [{
                            "id" : "1",
                            "correct" : "1",
                            "prompt" : "yes"
                    },
                    { 
                            "id" : "2",
                            "correct" : "0",
                            "prompt" : "no"
                    }]
            }]
     }]
}

This results in:

“Uncaught Error: You are using a ServerProxy but have not supplied it with a url.”.

Now my QuizModel has the required proxy to communicate to my REST API, but loading from questions() seems to use a default proxy. I’ve tried configuring the load call with the required parameters (including url and necessary api key) but this doesn’t appear to work. I can’t seem to find any documentation on how I should be doing this, and most related posts talk about localstorage only. Please help!

edit: adding my question list view:

BuddeMobile.views.QuestionList = Ext.extend(Ext.Panel, {
    title: 'Quiz',
    iconCls: 'quiz',
    cls: 'question',
    scroll: 'vertical',

    initComponent: function(){
        Ext.apply(this, {
            dockedItems: [{
                xtype: 'toolbar',
                title: 'Quiz'
            }],
            items:  [{
                xtype: 'list',
                itemTpl: '<div class="quiz-question">{prompt}</div>',
                store: 'quizStore',
                listeners: {
                    itemtap:  function (list, index, el, e){
                        console.log('question tap',el);
                    }
                }
            }]
        });

        BuddeMobile.views.QuestionList.superclass.initComponent.call(this, arguments);
    },
    updateWithRecord: function(record) {
        var toolbar = this.getDockedItems()[0];
        toolbar.setTitle(record.get('category')); //works

        var list = this.items.get(0);
        console.log(record.questions()); //prints out mixed collection of questions
        var question1 = record.questions().getAt(0); //testing
        console.log(question1.answers()); //prints out mixed collection for first question's answers
        list.update(record.questions()); //does not work. How can I populate the list??
    }


});

As you can see I can get the data I need (as I load the store upon login), but I don’t know how to make the list use the subset of data. I have tried the update function, but this isn’t doing a lot!

  • 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-05-30T05:24:20+00:00Added an answer on May 30, 2026 at 5:24 am

    I now have my quiz functioning correctly by using separate stores instead of trying to get the single nested store to do everything. To do this I had to make sure my server dealt out JSON models with foreign keys set accordingly. Example of my models & stores:

    app.models.Quiz = Ext.regModel("Quiz", {
        fields: [
            { name: 'id', type: 'int' },
            { name: 'studentid', type: 'int' },
            { name: 'dateAllocated', type: 'string' },
            { name: 'category', type: 'string' },
        ],
    
        associations: [
        {type: 'hasMany', model: 'Question', name: 'questions'},
    ],
    
        proxy: {
            type: 'rest',
            actionMethods: {create: "POST", read: "POST", update: "PUT", destroy: "DELETE"},
            url: 'http://localhost/bm/core/api/quiz',
            reader: {
                type: 'json',
                root: 'quizes',
                id: 'id'
            }
        }
    
    });
    
    app.stores.QuizStore = new Ext.data.Store({
        model: "Quiz",
        storeId: 'quizStore'
    });
    

    and the question model, note the field for quiz_id:

    app.models.Question = Ext.regModel("Question", {
        fields: [
            { name: 'id', type: 'int' },
            { name: 'quiz_id', type: 'int'},
            { name: 'prompt', type: 'string' },
            { name: 'level', type: 'int' },
            { name: 'category', type: 'string' }
        ],
        associations: [
            {type: 'hasMany', model: 'Answer', name: 'answers'},
            {type: 'belongsTo', model: 'Quiz'}
        ],
    
        proxy: {
            type: 'rest',
            actionMethods: {create: "POST", read: "POST", update: "PUT", destroy: "DELETE"},
            url: 'http://localhost/bm/core/api/questions',
            reader: {
                type: 'json',
                root: 'questions',
                id: 'id'
            }
        }   
    });
    
    app.stores.QuestionStore = new Ext.data.Store({
        model: "Question",
        storeId: 'questionStore'
    });
    

    This setup allowed me to have separate views for each store (Lists) that can be filtered depending on selection. Note that my API loads quizes/questions/answers only for the logged in user, so it’s not too much to load on login.

    Example of filtering a store for a particular list from a controller:

    showQuiz: function(options){
        //id passed from List's itemTap event
            var currentQuiz = app.stores.QuizStore.getById(options.id);
    
            app.stores.QuestionStore.clearFilter();
            //filter questions by selected quiz
            app.stores.QuestionStore.filter({
                property: 'quiz_id',
                value: options.id,
                exactMatch: true
            });
    
            //pass quiz record for setting toolbar title etc
            app.views.questionList.updateWithRecord(currentQuiz);
    
            app.views.quiz.setActiveItem(
                app.views.questionList, options.animation
            );
    
        }
    

    Hope this helps anyone running into the same problem!

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
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
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.