Dec 23, 2014, 3:51 PM
[CLOSED] TreeStore rejectChanges not working
Hi,
This is a follow up from this thread about Ext.NET 2:
http://forums.ext.net/showthread.php...coming-through
In that previous thread, we found a way to implement rejectChanges and commitChanges methods on the TreeStore because Ext JS 4 didn't have such methods.
Now, Ext JS 5 seems to, but, I am finding at least in my scenario it is not working.
Here is a modified version of the code posted in the previous thread, removing the tree store override, etc. I've also removed the custom writer stuff that the original thread started off about as it is not relevant here:
- Select a category node
- Press the delete button
Expect:
- Server returns error (as expected)
- Client side failure handler is invoked (as expected)
- It calls tree.getStore().rejectChanges(); but the tree does not show the node that failed to delete again...
- By comparison, the Ext.NET 2 version does show the node that failed to delete
Any thoughts/suggestions?
If you have access to Ext JS 5.1 beta, I am happy to wait to see if that fixes this?
Thanks!
This is a follow up from this thread about Ext.NET 2:
http://forums.ext.net/showthread.php...coming-through
In that previous thread, we found a way to implement rejectChanges and commitChanges methods on the TreeStore because Ext JS 4 didn't have such methods.
Now, Ext JS 5 seems to, but, I am finding at least in my scenario it is not working.
Here is a modified version of the code posted in the previous thread, removing the tree store override, etc. I've also removed the custom writer stuff that the original thread started off about as it is not relevant here:
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Title</title>
<ext:ResourcePlaceHolder Mode="ScriptFiles" />
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:TreePanel ID="TreePanel1" runat="server" Width="300" Height="200">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button Text="Delete" Icon="Delete">
<Listeners>
<Click Handler="
var tree = #{TreePanel1},
node = tree.getSelectionModel().getSelection()[0];
if (!node) return;
node.remove();
tree.getStore().sync({
failure: function(batch) {
tree.getStore().rejectChanges();
},
success: function() {
tree.getStore().commitChanges();
}
});
" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Root>
<ext:Node Text="Tasks" Expanded="true">
<Children>
<ext:Node Icon="Folder" Text="Delete this 0" Leaf="true" />
<ext:Node Icon="Folder" Text="Delete this 1" Leaf="true" />
<ext:Node Icon="Folder" Text="Delete this 2" Leaf="true" />
</Children>
</ext:Node>
</Root>
<Store>
<ext:TreeStore runat="server" AutoSync="false" ShowWarningOnFailure="false">
<Proxy>
<ext:AjaxProxy Url="TreeLoader.ashx">
<API Destroy="Destroy.ashx" />
<Writer>
<ext:JsonWriter RootProperty="data" Encode="true" />
</Writer>
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
</ext:TreePanel>
</body>
</html>
And destroy.ashx: public class Destroy : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
throw new NotSupportedException();
}
public bool IsReusable
{
get { return false; }
}
}
Steps:- Select a category node
- Press the delete button
Expect:
- Server returns error (as expected)
- Client side failure handler is invoked (as expected)
- It calls tree.getStore().rejectChanges(); but the tree does not show the node that failed to delete again...
- By comparison, the Ext.NET 2 version does show the node that failed to delete
Any thoughts/suggestions?
If you have access to Ext JS 5.1 beta, I am happy to wait to see if that fixes this?
Thanks!
Last edited by Daniil; Jan 20, 2015 at 6:06 PM.
Reason: [CLOSED]