1. #1
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    290
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default singleton = false still makes a singleton

    singleton = false still makes a singleton


    Hi all,

    I'm creating my stores like this (below), and I'm explicitely setting the singleton property to false. That's because I want multiple views containing the same entity but with different (server-side) filters.
    (Ie a grid with students from grade 1 and a second grid with students from grade 2).
    I want each grid to have it's own store.

    When I try to create a store, using Ext.create('My.store.StudentStore') I get the message
    "[Ext.create] ' 'My.store.StudentStore' is a singleton and cannot be instantiated

    But it shouldn't be a singleton, should it?
    Is this a bug or am I doing something wrong?

    Ronaldo


    Code:
    // Somewhere previously
    Ext.ns('My.app');
    Mt.url = {
        prefix: '/ext/',
        list:   '/list',
        create: '/create',
        save:   '/save',
        remove: '/delete'
    };
    
    // And then for every store a file containing
    
    Ext.require('Ext.data.Store');
    Ext.require('My.model.Student');
    Ext.require('Ext.data.Request'); 
    
    
    modelName = 'Student';
    
    
    Ext.require('My.model.'+modelName);
    
    
    Ext.define('My.store.'+modelName+'Store', {
        extend    : 'Ext.data.Store',
        singleton : false,
        requires  : ['My.model.'+modelName],
        model     : 'My.model.'+modelName,
        autoLoad: false,
        proxy: {
            type: 'ajax',
            api: {
                read    : My.url.prefix + modelName + My.url.list,
                create  : My.url.prefix + modelName + My.url.create,
                update  : My.url.prefix + modelName + My.url.save,
                destroy : My.url.prefix + modelName + My.url.remove
            },
            reader: {
                type : 'json',
                root : 'rows',
                totalProperty  : 'rowCount',
                successProperty: 'success'
            }
        },
        constructor : function() {
            this.callParent(arguments);
        }
    });
    Ronald van Raaphorst aka Ronaldo
    I'm a freelance software developer in Java, PHP, and ExtJs.


    Skyperonald_twensoc
    Mailinfo@twensoc.nl

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Thanks, we have a ticket open for this already in our tracker.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User Ronaldo's Avatar
    Join Date
    Jul 2007
    Location
    Enschede, The Netherlands
    Posts
    290
    Vote Rating
    0
    Ronaldo is on a distinguished road

      0  

    Default


    Hi,

    Thx! Sorry I didn't check the tracker first.
    It seems that by not mentioning the singleton property at all, it works just fine.

    Code:
    Ext.define('My.store.'+modelName+'Store', {    
      extend    : 'Ext.data.Store',
    //    singleton : false,    
      requires  : ['My.model.'+modelName],    
      model     : 'My.model.'+modelName,    
      autoLoad: false
    });
    Ronald van Raaphorst aka Ronaldo
    I'm a freelance software developer in Java, PHP, and ExtJs.


    Skyperonald_twensoc
    Mailinfo@twensoc.nl

Thread Participants: 1