1. #1
    Ext User
    Join Date
    Oct 2008
    Posts
    5
    Vote Rating
    0
    elpargo is on a distinguished road

      0  

    Default [2.2][CLOSED] SimpleStore is not extendable

    [2.2][CLOSED] SimpleStore is not extendable


    Hello I'm trying to implement a custom SimpleStore using extend but the follow code fails with
    http://www.extpaste.com/#1739

    config.id config is undefined (in firebug) at line 11103 in ext-2.2/ext-all-debug.js that line is the prototype for SimpleStore.

    The documentation for SimpleStore says id is optional, although setting id on my subclass does not solve the issue.

    as I said about I'm trying to implemente a ComboBox backed by a SimpleStore that will display different options depending on a parameter passes to the store at instantiation time.

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You assume that 'fields' and 'data' are properties, but they are only config options!

    Try:
    Code:
    Ext.namespace('projectone');
    projectone.NotSoSimpleStore = function(config) {
    	projectone.superclass.constructor.call(this, Ext.apply({
    		fields: ['name'],
    		data: [['=='], ['!='], ['>'], ['>='], ['<'], ['<='], ['contains'], ['not contains']]
    	}, config));
    }
    Ext.extend(projectone.NotSoSimpleStore, Ext.data.SimpleStore, {});

  3. #3
    Ext User
    Join Date
    Oct 2008
    Posts
    5
    Vote Rating
    0
    elpargo is on a distinguished road

      0  

    Default


    Thanks for your solution Condor, you are right I assumed the SimpleStore had fields for those which now I understand where not. Here is my current solution in case someone was looking for something similar. Also there is a little typo with your solution with the superclass call.

    Code:
    projectone.NotSoSimpleStore = function(config) {
            if (config.type == "string") {
                var mydata = [['=='], ['!='], ['contains'], ['not contains']];
            }
            else if (config.type == "int") {
                var mydata = [['>'], ['>='], ['<'], ['<=']];
            }
            else if (config.type == "date") {
                var mydata = [['>'], ['<']];
            }
            else {
                var mydata = [['=='], ['!='], ['>'], ['>='], ['<'], ['<='], ['contains'], ['not contains']];
            }
        projectone.NotSoSimpleStore.superclass.constructor.call(this, Ext.apply({
            fields: ['name'],
            data: mydata,
            }, config));
        }
    
    Ext.extend(projectone.NotSoSimpleStore, Ext.data.SimpleStore, {});

Thread Participants: 1