1. #1
    Banned
    Join Date
    Mar 2012
    Posts
    30
    Vote Rating
    1
    BackgroundTeam is on a distinguished road

      0  

    Default Answered: Reference to Store and Model (MVC)

    Answered: Reference to Store and Model (MVC)


    Hi everyone, maybe I'm doing something totally wrong, but you can see in this code, how I use one model and a store to do "things" in the listeners of the checkbox of the Main.js view.
    Well, if I want to put these store and model with the MVC architecture, with the folders "model" and "store" and so on, I don't really know how to reference them correctly, because I always have the error that in the listeners, there is a Reference Error.
    What am I doing wrong? How I could input a declaration in which I take the store and the model for sure?
    Thank you very much in advance. I know is a dumb issue, but I'm getting desperate with this.

    Code:
    Ext.define("modelomisOpciones", {
        extend: "Ext.data.Model",
        config: {
            fields: [
                {name: 'option', type: 'string'},
            ]
        }
    });
    
    var storemisOpciones = Ext.create('Ext.data.Store', {
         storeId: "storemisOpciones",
         model: "modelomisOpciones",
         proxy: {
                type: 'ajax',
                 url: 'app/store/misOpciones.json',
                reader: {
                    type: 'json'
                },
         },
     });
    
    Ext.define('Beetoom.view.Main', {
        extend: 'Ext.Container',
        config: {
        items: [
            {
            // ACTION
                xtype: 'checkboxfield',
                label: 'Action',
                listeners: {
                    check: function(){
                        console.log("Añadiendo...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.add({option: 'Action'});
                        console.log("Action se ha marcado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        console.log(storemisOpciones.getAt(index));
                        storemisOpciones.sync();
                        
                    },
                    uncheck: function(){
                        console.log("Quitando...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        var record = storemisOpciones.findRecord('option', 'Action');
                        storemisOpciones.remove(record);
                        console.log("Action se ha quitado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.sync();
                    }
                }
            },
            {
            // ADVENTURE
                xtype: 'checkboxfield',
                label: 'Adventure',
                listeners: {
                    check: function(){
                        console.log("Añadiendo...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.add({option: 'Adventure'});
                        console.log("Adventure se ha marcado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        console.log(storemisOpciones.getAt(index));
                        storemisOpciones.sync();
                    },
                    uncheck: function(){
                        console.log("Quitando...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        var record = storemisOpciones.findRecord('option', 'Adventure');
                        storemisOpciones.remove(record);
                        console.log("Adventure se ha quitado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.sync();
                    }
                }
            },
            {
            // NOIR
                xtype: 'checkboxfield',
                label: 'Noir',
                listeners: {
                    check: function(){
                        console.log("Añadiendo...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.add({option: 'Noir'});
                        console.log("Noir se ha marcado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        console.log(storemisOpciones.getAt(index));
                        storemisOpciones.sync();
                    },
                    uncheck: function(){
                        console.log("Quitando...");
                        var index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        var record = storemisOpciones.findRecord('option', 'Noir');
                        storemisOpciones.remove(record);
                        console.log("Noir se ha quitado");
                        index = storemisOpciones.getCount() - 1;
                        console.log("Indice: " + index);
                        storemisOpciones.sync();
                    }
                }
            },
            {
                xtype: 'button',
                text: 'Ver!',
                handler: ledoy = function(e) {
                        console.log("Se han metido " + storemisOpciones.getCount() + " opciones");
                        Ext.Viewport.setActiveItem({
                                // xclass: '' 
                            xtype: 'list',
                            itemTpl: '{option}',
                            store: storemisOpciones
                        });
                        
                }            
            }
        ]
    }
    });

  2. You can give your store a storeId and then you can resolve that store using Ext.getStore passing in the storeId.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can give your store a storeId and then you can resolve that store using Ext.getStore passing in the storeId.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Banned
    Join Date
    Mar 2012
    Posts
    30
    Vote Rating
    1
    BackgroundTeam is on a distinguished road

      0  

    Default


    Thank you, Mitchell!

    So a solution could be:
    Code:
    var storemisOpciones = Ext.getStore('myStoreID')
    and then use it in the listeners?

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Answers
    3462
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Yup, all you have to do is something like

    Code:
    storemisOpciones.on('load', someFunction, storemisOpciones);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Banned
    Join Date
    Mar 2012
    Posts
    30
    Vote Rating
    1
    BackgroundTeam is on a distinguished road

      0  

    Default


    Ok! Thank you as always, Mitchell!

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."