-
18 Aug 2010 6:14 AM #1
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?
-
23 Aug 2010 1:50 PM #2
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.
And here is how I delete.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 }), });Code:var store = grid.getStore(); var record = store.getById(serialNo); if (record) { store.remove(record); store.save(); }
-
23 Aug 2010 6:42 PM #3
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 } } }
-
23 Aug 2010 9:34 PM #4
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????Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
24 Aug 2010 1:33 PM #5
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.
And the store configuration.Code:{"ItemCount":0,"Items":[],"Message":null,"Success":true}
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
-
RESTful Store and some problems with it (dirty records, callback 'write' on Writer)
By StyleWarz in forum Ext 3.x: Help & DiscussionReplies: 13Last Post: 31 Mar 2010, 1:11 AM -
Updating Grid PagingToolbar when deleting or adding records
By gh0st26 in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 25 Jan 2010, 5:12 PM -
Deleting multiple records
By ketanAtExt in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 4 Feb 2008, 11:15 AM -
Grid and deleting records (example)
By Ronaldo in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 4 Jul 2007, 12:13 PM


Reply With Quote