1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    Kolkata
    Posts
    9
    Vote Rating
    0
    Saurav.Mittal is on a distinguished road

      0  

    Default Answered: How to have multiple Stores implement the same model and load it correctly?

    Answered: How to have multiple Stores implement the same model and load it correctly?


    Hi Guys,

    I ran into a trivial issue, in my app, I want to have a question bank with a set of Q&A for each specific subjects and want to have an individual Store for each subject. As all the question bank fields would be same, i would like to have a single Model and have all Stores follow that model. How can this be achieved or the best way to do it?

    Now, the weird problem is when i implement - When i assign the store to the List, the store which is mentioned last in the declaration (app.js) shows up in data irrespective of the Store I load.

    Code:
    app.js
    stores: ["Java","C","DBMS"],
    
    My view:
    xtype: "list",
                store: Ext.getStore("C"),
                itemTpl: '{id}. {q}',
    Even though i pass C store, the q field from DBMS store gets loaded in the view but id (the question number) is equal to the no. of questions/records in C store, not DBMS store. My model and Store defs.

    Code:
    Model:
    ---------
    Ext.define("IApp.model.Questions", {
        extend: "Ext.data.Model",
        config: {
            idProperty: 'id',
            fields: [
                { name: 'id', type: 'int' },
                { name: 'q', type: 'string' },
                { name: 'a', type: 'string' }
            ]
        }
    });
    ---------------------------------------------------------------------
    Stores:
    --------
    Ext.define("IApp.store.C", {
        extend: "Ext.data.Store",
        config: {
            model: "IApp.model.Questions",
            data: [
            {id:1, q:'This is 1st question for C language', a:'This is 1st answer for C language'},
    ------------------------------------------------------------------------------------------
    Ext.define("IApp.store.DBMS", {
        extend: "Ext.data.Store",
        config: {
            model: "IApp.model.Questions",
            data: [
               {id:1, q:'This is 1st question for Database', a:'This is 1st answer for Database'},

  2. If you change the name of your id field from id to something else (e.g. uid) I imagine your problem will be fixed.

  3. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    164
    Answers
    13
    Vote Rating
    9
    in4p will become famous soon enough

      0  

    Default


    If you change the name of your id field from id to something else (e.g. uid) I imagine your problem will be fixed.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    Kolkata
    Posts
    9
    Vote Rating
    0
    Saurav.Mittal is on a distinguished road

      0  

    Default


    Thanks a lot! It worked, and after looking at idProperty of the Model class, I understood the reason too.

    Thank you once again!
    Regards..

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar