I'm adding new item to TreeStore with rest proxy, and doing store.sync
Code:
Ext.create('Ext.data.TreeStore', {
            fields: storeFields,
            autoLoad: false,
            autoSync :false,
            clearOnLoad: true,
            proxy:{
                type:'rest',
                format:'json',
                url:me. url,
                extraParams:{},
                reader:{
                    type:'json'
                },
                api:{
                    read:me.url,
                    update: updateurl,
                    create:me. newurl,
                    destroy:me.deleteurl
                },
                writer:{
                    type:'json',
                    nameProperty:'mapping',
                    root:'root',
                    record:'root',
                    writeAllFields:false
                },
                listeners:{
                    exception:function (proxy, response, operation) {
                        Ext.MessageBox.show({
                            title:'Error',
                            msg:JSON.parse(response.responseText).message,
                            icon:Ext.MessageBox.ERROR,
                            buttons:Ext.Msg.OK
                        });
                        this.load();
                    }
                }
            },
            listeners:{
                beforeload:function (store) {
                    store.proxy.appendId = false;
                },
                load:function (store) {
                    store.proxy.appendId = true;
                },
                beforesync:function (options, eOpts) {
                },
                write:function (store, operation) {
                  store.load()
                }
            },
            folderSort:true

        });
Code:
store.getNodeById(id).appendChild(record);
store.sync();
The problem is when sync end up with error. I don't know how to reject changes in store.
In exception listener: there's
Code:
this.load();
It reload's the store from server. My new added item is not visible anywhere.
But then again I add another record (record2) and it's trying to send new record and previous ended with failure.
Again I add record(record3) and it's sending record2 as well (but not the first one).
Again I add record(record4) and it's sending record3 as well (but not the firsrt one and record 2). Only previous is beeing sent.
I'm reloading store 1,2,3,4 times, but again trying to add record5 it's sending record4

Where I can find this dirty record and throw it away. I'm using clearOnLoad = true, but it still there till next errror.

And there's more. If next record6 is ok and sync won't get failed, but record5 is send and tree is messed up. I need to refresh page, as it cannot get back to normal state