A possible use case: in TreePanel.beforeNodeDrop(), I want to perform server-side rather than client-side validation of the drop so that the logic about valid drop locations doesn't have to reside in the client. beforeNodeDrop() must return false to stop the drop, but it returns without receiving a response from the server. The server response can only be captured in the callback, but from there you can't control what beforeNodeDrop() returns. Is there a way to do this other than using a synchronous call?
This was just the sort of use case I was going to post: server side validation of some data before proceeding: thats precisely the situation I find myself in today (albeit having nothing to do with TreePanel, because I get the impression from grepping the ExtJS 3 source code this may have been addressed though I'm not positive).
But just being asked to provide a use case in such a terse way is bad customer relations in my opinion.
We have some tree. Each node of this tree corresponds to some data record in database table on server. For example we have table that contains hierarchy of product categories of internet-shop (task list in project management system, groups and users in instant messenger store, ...) - in any real project tree data structure is used.
Now... We have UI built on ExtJS library. TreePanel, TreeNode, ... and TreeEditor. Some user (admin, project manager, IM user, ...) tries to rename node of tree. What do we need? We have to send request to web server where some server application should save changed data to database. And this request can be whether successful or not. And we must not do something with tree node before we get response (success or failure) from server.
ExtJS. TreeEditor. What can we do during renaming node? We can subscribe on 'beforecomplete' event and create request there. But we have to cancel or submit edit at once. So user will see whether renamed node or old name in incorrect way. Because maybe renaming won't be done in the database.
And there are many cases when UI mustn't be changed before response from server comes. Because if we can't use UI library bound to real data it's meaningless.
I think I've described use case in depth. So, if somebody can explain me how I should realize it with ExtJS I will be very thankful. Because I decided to try using ExtJS in some project about two months ago and if to be honest I am very disappointed so far...
PS And this issue happens when any update (data changes) takes place... For more example - drag'n'drop functionality...
Originally Posted by Animal
Can anyone provide a use case for synchronous requests?
I do not like to show user anything.
I must show user correct information in right way like he wants.
The tree shows some data. And it hasn't to show anything else.
When we do something there (renaming, dragging, ...) some result of this action is.
And we need to show there something. Submitted, canceled, somethings else...
But we don't want it.
What should I show in tree you think? "I'm sorry, this item is being loaded".
Do I need to submit changing? Or cancel?
It's ridiculous... Really...
PS Of cause I can hack ExtJS as I'd like and do anything what I want. And maybe nothing will remain from original one. And now I'm doing it unfortunately. Of cause anything can be done.
But we are living in 21st century. And it's very strange to have API that does not decide typical use cases by two lines of code. It seems sort of WinAPI... When I saw for example that I needed to override 'renderElements' method (TreeNodeUI) to show shomething esle in tree and needed to repeat there all activities from parent method... Really, I just thought about MFC and smiled...
By the way... ExtJS customers are people all around the world. They ('customers') wants to have solution for some use cases. It will be suitable to use sync AJAX they suppose. Why doesn't ExtJS want to satisfy their wishes but offers some solutions that can not satisfy them?
PPS One more use case. About drag'n'drop. I drag node from one tree to other one. When I drop item there are only two ways - whether to commit drop or cancel. When I drop item also I send request on server and must not insert new item in target tree as I must not show flying node to source tree if I cancel drop. I should do it only when response comes.