1. #1
    Ext User
    Join Date
    May 2010
    Posts
    1
    Vote Rating
    0
    arboooz is on a distinguished road

      0  

    Default Restful grid deleting multiple records

    Restful grid deleting multiple records


    Hi all,

    i found a bug. When i`am trying delete multiple records in grid using restful remote store (similar to that one http://dev.sencha.com/deploy/dev/exa...l/restful.html), records disapears and then it sends duplicated requests, so records are showing back (also duplicated), until i press refresh record located down the grid.

    Anyone has seen similar problem? and maybe have a solutions for this?

  2. #2
    Sencha User
    Join Date
    Jun 2007
    Location
    Minneapolis, MN
    Posts
    12
    Vote Rating
    0
    exquisitus is on a distinguished road

      0  

    Default


    My situation is a tad different but yes, I remove a record and then it re-appears. Eventhough it has been deleted on server-side. Below is my store setup. No auto save. Are we missing something. Is the server-side expected to return a success flag in the response? Need help.

    Code:
    var store2 = new Ext.data.JsonStore({
            url: 'MyFareCardList.ashx',
            autoDestroy: true,
            autoLoad: true,
            autoSave: false, // do not send RESTFUL request for each cell edit
            idProperty: 'SerialNumber',
            storeId: 'myStore',
            sortInfo: { field: 'SerialNumber', direction: 'ASC' },
            root: 'Cards',
            totalProperty: 'TotalCount',
            fields: [
                { name: 'SerialNumber' },
                { name: 'NickName' },
                { name: 'Response' }
            ],
            restful: true,
            writer: new Ext.data.JsonWriter({ encode: false }),
        });
    And here is how I delete.
    Code:
    var store = grid.getStore();
            var record = store.getById(serialNo);
            if (record) {
                store.remove(record);
                store.save();
            }

  3. #3
    Sencha User
    Join Date
    Jun 2007
    Location
    Minneapolis, MN
    Posts
    12
    Vote Rating
    0
    exquisitus is on a distinguished road

      0  

    Default


    More info:

    I have attempted to debug this with Firebug. Using ExtJS version 3.2.1. The function onDestroyRecords (code below) is one of the last functions called by the Store.save() function. I debugged this and the value of the success parameter is false. I find this puzzling because the server-side is responding with HTTP 200 OK. At least I now know why a removed record disappears only to re-appear when the server responds. Now I just need to figure out where the false value is coming from. Oh well I haven't given up yet, but I am almost getting there. I am hoping that someone can point me in a direction iin my debugging attempt.
    Code:
    File src/data/Store.js lines 1166 - 1179
    // @protected onDestroyRecords proxy callback for destroy action
        onDestroyRecords : function(success, rs, data) {
            // splice each rec out of this.removed
            rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
            for (var i=0,len=rs.length;i<len;i++) {
                this.removed.splice(this.removed.indexOf(rs[i]), 1);
            }
            if (success === false) {
                // put records back into store if remote destroy fails.
                // @TODO: Might want to let developer decide.
                for (i=rs.length-1;i>=0;i--) {
                    this.insert(rs[i].lastIndex, rs[i]);    // <-- lastIndex set in Store#destroyRecord
                }
            }
        }

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    62
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    And how are you error trapping in that Store?

    If the response cannot be read, and the Store never gets a successful response to a delete????

  5. #5
    Sencha User
    Join Date
    Jun 2007
    Location
    Minneapolis, MN
    Posts
    12
    Vote Rating
    0
    exquisitus is on a distinguished road

      0  

    Default


    I figured it out my issue after spending more time inspecting the RESTful Store GridPanel demo.

    The server-side needs to return a specific JSON response. Most importantly a Success property and a Message property. And the store needs to be configured for such properties, e.g. below. Previously I assumed that returning HTTP 200 OK was good enough. My assumption was incorrect.

    Sample of expected server-side response.
    Code:
    {"ItemCount":0,"Items":[],"Message":null,"Success":true}
    And the store configuration.
    Code:
    var store2 = new Ext.data.JsonStore({
            url: 'MyFareCardList.ashx',
            autoDestroy: false,
            autoLoad: true,
            autoSave: false,
            idProperty: 'SerialNumber',
            storeId: 'myStore',
            sortInfo: { field: 'SerialNumber', direction: 'ASC' },
            root: 'Items',
            totalProperty: 'ItemCount',
            successProperty: 'Success',
            messageProperty: 'Message',
            fields: [
                { name: 'SerialNumber' },
                { name: 'NickName' },
                { name: 'Response' }
            ],
            restful: true,
            writer: new Ext.data.JsonWriter({ encode: false })
        });

Similar Threads

  1. Replies: 13
    Last Post: 31 Mar 2010, 1:11 AM
  2. Updating Grid PagingToolbar when deleting or adding records
    By gh0st26 in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 25 Jan 2010, 5:12 PM
  3. Deleting multiple records
    By ketanAtExt in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 4 Feb 2008, 11:15 AM
  4. Grid and deleting records (example)
    By Ronaldo in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 4 Jul 2007, 12:13 PM

Thread Participants: 2