PDA

View Full Version : Server update after every element drag



Yoyo
4 Aug 2007, 3:39 AM
Hi there, it is my first post here.

At first sorry for my bad English.

I'm considering Ext for my next project - for one reason alone - Tree component. And before deciding I want to be sure if Ext will allow me to do such a thing:



User grabs a TreeNode to reorder.
After dropping it, request is send to server with reorder query.
If server responds with success state - well, nothing will happen - node will gain a new place.
If server responds with error state (or timeout) - node will back to its original position and error message will pop up.


I was browsing Api docs and found "beforemove" event in TreePanel (http://extjs.com/deploy/ext/docs/output/Ext.tree.TreePanel.html#event-beforemove) object, which lets me abort moving a node. The problem is that server requests will be asynchronous...

How do you deal with such things?

evant
4 Aug 2007, 4:32 AM
If you must check the server before the node is dropped, I'd suggest you block access to the tree using Ext.MessageBox.

However, it's not really preferable to do this. Can you move your check to the client side?

Yoyo
4 Aug 2007, 2:51 PM
However, it's not really preferable to do this. Can you move your check to the client side?

Well, it's not a check... it's actually database update. I mean, it should be done after every drag - without "save" button. And as for me, blocking UI by messagebox sounds not like a good idea.

So, let's put it another way - how it should be done with Ext? How do you program error-proof server updating of reordered tree?

evant
4 Aug 2007, 5:27 PM
Yes, but is there any reason your database update should fail?

The callback runs asynchronously, the only decent way to do it is to block the user interface while the callback occurs, otherwise the user can interact with it in a possibly invalid state.

Yoyo
4 Aug 2007, 7:48 PM
Yes, but is there any reason your database update should fail?

Well, why not? it could be server, database, lost connection, lost session, out of reach if you are on GPRS connection, ISP lunch break, power outage on one side or earthquake in between... Damn, happens - more often than expected :)


The callback runs asynchronously, the only decent way to do it is to block the user interface while the callback occurs, otherwise the user can interact with it in a possibly invalid state.

That should be no problem. The problem is how to rollback node's position after failure update?

And as a side note - how do you actually create such a editable tree for yourself in real application environment? I mean - do anyone care about possibility of not succeeded request to server, or you just assume that there gonna be none? Or is there any other error-proof way of updating changes made client site by user?