1. #1
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Exclamation DirectStore not writable? Doesn't work with Direct Providers?

    DirectStore not writable? Doesn't work with Direct Providers?


    Shouldn't the creation of a directStore also create a writer based on the passed api? I figured if I passed in an api with a create and update that a directStore would know what to do with them...

  2. #2
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Default


    OK, now I have added my own writer. So closer, but now it doesn't have enough parameters when creating. My API actions are defined as follows:

    Code:
    [
    { "name":"update", "len":2 } ,
    { "name":"create", "len":1 } ,
    { "name":"destroy", "len":1 } ,
    { "name":"read", "len":0 } 
    ]
    and the store:

    Code:
    store = new Ext.data.DirectStore({
    	autoSave: false,
    	reader: reader,
    	api: api,
    	paramsAsHash: false, // without this it won't actually read, nor return an error about it
    	writer: writer
    });
    The first thing you'll notice is that I have paramsAsHash set to false. I have to do this because of a bug that the read call expects no parameters, but with paramsAsHash set to true it adds one anyway, and then the callback is in the wrong place and it never gets called, thus the store doesn't know that the ajax request is ever finished.

    Anyhow, even changing that back to true doesn't work.

    I thought that a DirectStore would just consume a DirectProvider api and be done with it. What am I missing? How can I get this to work?

  3. #3
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Default


    The first issue is easily remedied by having the DirectStore create a writer if using an api instead of a directFn. The second issue is fixed by setting root to '' when root is undefined. The issue with wrong param count for api.read is fixed by defaulting paramsAsHash to false, not true.

  4. #4
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,407
    Vote Rating
    6
    stever will become famous soon enough stever will become famous soon enough

      0  

    Default


    Fourth issue: you can't write/create on a store that hasn't been loaded yet since realize calls extractValues without checking first to see if buildExtractors was called, resulting in calls to this.ef[j](data) where this.ef is not defined.

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,054
    Vote Rating
    659
    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


    #4 - Try SVN.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1