PDA

View Full Version : prevent from making certain CRUD action



Raz0r
31 Oct 2009, 8:44 AM
Hi!
I need to remove a record from the store but I don't want Ext to make a call to the server-side with "destroy" CRUD action. So, my code is:

store.remove(someRecord);
At the same time, this is the only piece of code that needs the "destroy" action to be disabled - all the other handlers should generate this action on a record removing. I thought about subscribing to the "remove" event and returning "false", but that didn't help.
How can I prevent Ext from making "destroy" action? Btw, this is needed for drag and drop functionality.
Any help will be much appreciated :)

Raz0r
1 Nov 2009, 3:07 AM
The solution was rather easy, I just added a new listener above that line but to the "beforewrite" event and with option "single" = "true":

ds.addListener('beforewrite', function(){
return false;
}, this, {
single: true
});

Mike Robinson
2 Nov 2009, 7:42 AM
I would suggest that you handle such things mostly (or also...) on the server side.

In general, the client-side is not to be trusted. It might do the wrong thing, intentionally or otherwise. If a request such as "destroy" is not to be honored in a particular case, then not only should the client-side framework include checks not to issue the request, but the server must also contain checks not to honor it. The server should throw a very unmistakable exception, creating "a big-enough explosion of protest" that the client-side bug can't be ignored or overlooked.

Raz0r
2 Nov 2009, 7:54 AM
Thanks for your proposal. However the matter is that it is very difficult to distinguish on the server side between the items to be destroyed as they are all of the same type (only IDs are passed). So, it is impossible to trace on the server side whether this particular item has to be destroyed or not (in my case at least).