[CLOSED] TreeStore rejectChanges not working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [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:

    <%@ 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]

Similar Threads

  1. [CLOSED] TreePanel & TreeStore setRootNode() not working anymore?
    By cleve in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2013, 3:16 PM
  2. Replies: 5
    Last Post: Dec 13, 2012, 8:27 AM
  3. Replies: 2
    Last Post: Jun 06, 2012, 8:27 PM
  4. [CLOSED] .rejectChanges not removing an added row
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 27, 2011, 3:15 PM
  5. About Store.rejectChanges method
    By sunny_sh in forum 1.x Help
    Replies: 2
    Last Post: Aug 09, 2009, 11:43 PM

Posting Permissions