Results 1 to 2 of 2

Thread: Store.sync() destroy action

  1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    80
    Vote Rating
    1
      0  

    Default Unanswered: Store.sync() destroy action

    Hello,
    I am trying to get store.sync() to work. I have it working great with updating and adding records. I can't get it to tell the server that it is destroying a record.

    this is the basic sync code that I am calling.
    Code:
    Store = Ext.StoreMgr.lookup('locationsStore');
    Store.sync({
        success: function (batch, opts) {
            console.log(batch);
        },
        failure: function (response, opts) {
    
    
        }
    
    
    });
    It calls my php file twice, once for modifying the record and once for destroying it (when there is a add and destroy action to be full filled).

    As you can see from the console log it does two operations, an update and destroy. How can I get it to tell the PHP application what operation it is performing?

    Code:
    i {proxy: i, listeners: null, hasListeners: e, events: Object, operations: Array[2]}
    
    • current: 1
    • events: Object
    • exceptions: Array[0]
    • hasException: false
    • hasListeners: e
    • isComplete: true
    • isRunning: false
    • listeners: null
    • operations: Array[2]
      • 0: i
        • action: "update"
        • batch: i
        • complete: true
        • records: Array[1]
        • request: i
        • response: Object
        • resultSet: i
        • running: false
        • started: true
        • success: true
        • __proto__: a
      • 1: i
        • action: "destroy"
        • batch: i
        • complete: true
        • records: Array[1]
        • request: i
        • response: Object
        • resultSet: i
        • running: false
        • started: true
        • success: true
        • __proto__: a
      • length: 2
      • __proto__: Array[0]
    • proxy: i
    • total: 2
    • __proto__: a
    the Form data it post is identical except for the json data it is passing.

    Any help will be appreciated, thanks

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    100
      0  

    Default

    such problems mostly occur when an id field is not being properly used. Do you have an id field in of type int in your model? if you are using some other name for your id field, you have to specify it in the proxy's ready using idProperty config.

    Other than that, you can check e.g. after calling store.remove() to delete a record, do the following:

    Code:
    console.log(store.getNewRecords());
    console.log(store.getRemovedRecords());
    console.log(store.getUpdatedRecords());
    only getRemovedRecords should return the record to be deleted and the other two should return an empty array if you didnt add or update any record.

Posting Permissions

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