Results 1 to 3 of 3

Thread: [0.7.10] remote records are not properly imported into stores

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Aug 2012
    Vote Rating

    Default [0.7.10] remote records are not properly imported into stores

    Versions: 0.7.10 (and 0.7.8) with Sencha Touch 2.1.1
    Browser: Chrome 24 (Win8 / Desktop)
    Severity: normal
    Attachment: 0.7.10 patch proposal

    When a record receives a new global ID (e.g. id: 2 (local) -> id: b9-67779170 (remote)), store filters, groupers and sorters are not correctly applied, which can lead to inconsistencies in views. For instance, the record will not be sorted in the list, grouped lists will not display the group header on the correct item or a record which no longer matches filters will stay displayed in list instead to be removed. These artifacts will disappear - for faulty records - after an app reboot.

    Test case

    I used the 'examples/touch/todo' example without modification (note that it's one test case among many other).

    - Create 3 tasks with titles: "A", "B" and "C" (the list now contains 3 items in this order: C, B, A)
    - Edit C, change "completed" to true and save: C is now strikeout but remains at the first position
    - Edit A, change "completed" to true and save: A is now strikeout at the last position

    Expected order would be: B, A then C (and not C, B, A), because the 'todos' store defines the following sorters:
    PHP Code:
    sorters: [
    property 'completed',
    property 'timestamp',
    - Relaunch the app: the list is correctly ordered.


    Two reasons can explain this issue: first, you silently change the record local id to its new oid in the create method (cf/data/SyncProxy.js). By doing that, objects which maintain an internal map based on this record id will not be notified about id modification (which is exactly the case for group in stores). I fixed it by using record.set() despite the developer comment. I don't known side effects about using this method, or if it was just an optimization but it fixed lot of issues in my project.
    PHP Code:
    // the user id is the oid.
       //[this.idProperty]= record.getOid(); // warning: don't call record.set, it'll cause an update after the add

        // FIX: above message warns about not calling record.set, but
        // record ID related notifications should be performed in order
        // to update existing ID mapping (for instance store internal
        // data indices used by grouped lists).
    The second reason is that imported records are not joined to the store, but directly added to its internal data. It takes place in the updateStore method (io/data/Proxy.js). I fixed this by explicitly joining records to the updated store:
    PHP Code:
    updateStore: function(store,createdRecords,updatedRecords,removedRecords){
    changed false;
    createdRecords && createdRecords.length>0) {

    // FIX: we need to join the store for created records in
                // order to have store notifications on record updates.
    Ext.each(createdRecords, function(record) {

    changed true;
    updatedRecords && updatedRecords.length>0) {

    // FIX: we need to join the store for updated records in
                // order to have store notifications on record updates.
    Ext.each(updatedRecords, function(record) {
    I attached the full patch over 0.7.10 used for my project.
    Attached Files Attached Files

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