1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    53
    Answers
    2
    Vote Rating
    2
    manilodisan is on a distinguished road

      0  

    Default Unanswered: model.save() and the required server response

    Unanswered: model.save() and the required server response


    I have a model with a rest proxy (json reader/writer) defined. The json reader has the 'totalProperty' set to 'pagination.total_entries' as per my internal setup using rails 3 and 'will_paginate' gem.

    Everything works fine when I query the records to show them in a grid but when I try to save a new model instance I get the 'failure' callback hit instead of success even though I respond with the 'success: true' message along with the newly created object.

    Digging the failure operation param I get the following message: 'error: "Cannot read property 'total_entries' of undefined"' which means that the save operation looks for the pagination object (totalProperty) in the response. If I add a dummy pagination.total_entries = 1 in the response the success callback is hit but it seems pretty weird for extjs to seek for 'totalProperty' when I'm saving a record.

    Is this expected behavior and I'm supposed to respond with this dummy in all my create actions?

    Why is extjs expecting a collection-type response when I'm working with a single record (POST/PUT)?

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    Normally you shouldn't have to provide the total property on a save. At least I never do and it works fine.

    Hunch: What might be the case is that standard the reader searches for the total property and fails silently if it cannot find it. However in this case it is trying to traverse nested JSON that doesn't exist and it doesnt get to failed silently on a undefined property, since it is trying to dereference an undefined before that.

    What happens if you specify just an empty object pagination in the json result?

  3. #3
    Sencha User
    Join Date
    Mar 2008
    Posts
    53
    Answers
    2
    Vote Rating
    2
    manilodisan is on a distinguished road

      0  

    Default


    Quote Originally Posted by flanders View Post
    What happens if you specify just an empty object pagination in the json result?
    It works but it's a dumb approach to force the server to send such data just for extjs to play nice. Why should the reader look for a collection (total) when I'm posting a record. I'm using 4.1* by the way.

  4. #4
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    I agree with you, that is dumb. However, I do not think that ExtJS is trying to force you to send that empty object. I think its just a bug (or actually more like a flaw) and think you should write a bugreport.

    It was just a test to confirm my suspicion

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar