Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Posting data to server

  1. #11
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242

    Default

    Your code looks alright and since I had difficulties letting the proxies on models work, maybe there is also something wrong with proxies on direct stores. I don't use php, but I will do a test similar to yours and will try to find what's wrong.

  2. #12

    Default

    I did notice last night while doing some debugging I have the line this.getScorecardsStore().api = {...}. However in debug if I look at the store object the api property is just Object{}. nothing is defined within it. But I would assume it has to be working otherwise It wouldn't pull the data from the server query in in the first place. Second thing I noticed when I looked at some of the classes when the exception was thrown that the 'action' that the proxy is trying to perform is 'create' not 'update' which could possibly explain the No url exception method because I have not defined a 'create' method in my direct API. I'm at work now so ill play with that tonight. Just some food for thought

  3. #13
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242

    Default

    The create action is called for existing records when the idProperty is not set to the field containing the record id's.

    idProperty's default value is 'id', but your model has Id (capital i), so adding idProperty: 'Id' to the model's config will probably solve this.

    Code:
    Ext.define('TeamTracker.model.Scorecard' ,{
        extend: 'Ext.data.Model',
        fields: ['Id','Name','Owners'],
        idProperty: 'Id', // <--- must match the id field in fields
        validations: [{
            type: 'length',
            field: 'Name',
            min: 1
        }, {
            type: 'length',
            field: 'Owners',
            min: 1
        }], 
    });
    HTH

  4. #14

    Default

    Good catch but unfortunatly didn't change anything still getting the ServerProxy error. I'd like to put this up on GitHub tonight it seems this thread is generating alot of views I'd like to see some people get a hold of this and see the changes rather than us just going back and forth.

  5. #15

    Default

    Unfortunately I didn't get to do anything I wanted today cause of a late day at work however I did put a new implementation of direct in the files that works pretty well. I posted it up on github

    https://github.com/ThrowsException/TeamTracker

  6. #16

    Default

    So im getting a little closer. Now when I hit save i'm getting a POST response =) . right now I'm just returning the $params that went into the call but it contains the changes I made to the object on the grid. I should be able to post the changes tonight. Twaindev I went with your suggestion and moved my proxy into my model with your hack on the store and so far this seems the most promising direction to take.

  7. #17
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242

    Default

    Good to hear you're making some progress.

    The proxy on the model works fine and it has the advantage of loading and saving records without a store.

    But I still want to find out why the other option doesn't work.

  8. #18

    Default

    Sounds good but i'll tell ya aftter diving through source code and debugging for almost a week straight I got almost no where with the way I had the project set up so I don't know how far you want to go down that path.

    I've put up some updated code on github. My next thing now is, and I think I saw similar post on this, when I save, either with record.save() or store.sync(), How do I get the grid to get rid of the little red triangles? Something my php method should return?

  9. #19
    Sencha Premium User twaindev's Avatar
    Join Date
    Sep 2009
    Posts
    242

    Default

    Just return { success: true }.

    For submits with server side validation you can optionally return an additional errors object like this:

    Code:
    {
        success: false,
        errors: {
             username: 'The username is already taken.',
             password: 'Password should be 8 characters or more'
        }
    }
    You can read more about it here.

  10. #20

    Default

    of course I am returning success : true and of course it doesn't work lol. For something they seems to push so hard Ext.Direct does not seem to be very friendly.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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