Results 1 to 4 of 4

Thread: Extending a directStore which includes a reader

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    4

    Question Extending a directStore which includes a reader

    Hi,

    what i'm trying to achieve is to create a custom store which includes a reader.
    I'm able to break it to the following minimal example:
    Code:
        testStore = Ext.extend(Ext.data.DirectStore, {
            reader: new Ext.data.JsonReader(),
            writer: new Ext.data.JsonWriter()
        });
    An instance of the resulting store has the expected writer attribute, but the reader attribute is undefined. What am i missing here?

    What i've also tried is to assign the reader in the constructor method of my store:
    Code:
        testStore2 = Ext.extend(Ext.data.DirectStore, {
            constructor: function(){
                Ext.apply(this, {
                    reader: new Ext.data.JsonReader()
                });
                testStore2.superclass.constructor.apply(this, arguments);
            },
            writer: new Ext.data.JsonWriter()
        });
    In this case, the resulting store has a reader, but only as long as i don't call the constructor of his superclass (marked red).

    It would be great if someone could point me in the right direction here.. thank you

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    A DirectStore is nothing more than a Store with a preconfigured DirectProxy and a JsonReader.

    If you want to specify your own proxy or reader, then why not start with a normal Store instead of a DirectStore?

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    4

    Default

    Ah, thank you Condor. Extending a normal store works perfectly.

    Just out of curiosity, why did my approach fail? Shouldn't i be able to overwrite the reader in the constructor?

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    No, the reader will be replaced by the superclass (=DirectStore) constructor.

Similar Threads

  1. [FIXED-466][3.1/3.1.1] DirectStore reader bug
    By Hacker-CB in forum Ext 3.x: Bugs
    Replies: 50
    Last Post: 9 Mar 2010, 9:52 PM
  2. [FIXED-384][3.0.3] DirectStore does not create Reader
    By Gjslick in forum Ext 3.x: Bugs
    Replies: 3
    Last Post: 14 Dec 2009, 11:00 PM
  3. ext-all is too big please help for Includes
    By mclerte in forum Ext 2.x: Help & Discussion
    Replies: 12
    Last Post: 29 Oct 2007, 3:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •