Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-8267 in 4.2.0.489.
  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    5
    Vote Rating
    1
    emixion is on a distinguished road

      1  

    Default TreeStore sends DELETE request for phantom nodes

    TreeStore sends DELETE request for phantom nodes


    REQUIRED INFORMATION
    Ext version tested:
    • Ext 4.1.1
    Browser versions tested against:
    • Chrome 25
    DOCTYPE tested against:
    • HTML
    Description:
    • A DELETE request is sent for phantom nodes (nodes not known remotely yet) on manual sync.
    Steps to reproduce the problem:
    • create a treestore with REST proxy
    • create a treepanel using that store
    • create a new node
    • append that node to the tree rootnode
    • remove that node again
    • sync the treestore
    The result that was expected:
    • Not any HTTP request
    The result that occurs instead:
    • A DELETE HTTP request for the new node
    Test Case:
    PHP Code:
    // define the REST store
    var store Ext.create('Ext.data.TreeStore', {
        
    proxy: {
            
    type'rest',
            
    url'test-nodes.json',
            
    appendIdfalse,
            
    reader: {type'json'root'data'},
            
    writer: {type'json'}
        }
        ,
    root: {
            
    text'root',
            
    id'root-1',
            
    expandedtrue
        
    }
    });


    // create the tree
    var tree Ext.create('Ext.tree.Panel', {
        
    storestore
        
    ,title'sync phantom records test'
        
    ,renderTo'tree-example'
    });


    //add a new node, remove it, sync
    var newNode store.model.create({text'dont sync me, im a ghost'}),
        
    root tree.getRootNode();
    console.log('new node is phantom:'node.phantom);
    root.appendChild(newNode);
    root.removeChild(newNode);
    store.sync(); // <--- a DELETE request for a node not known on the server is sent 
    HELPFUL INFORMATION
    Testcase:
    • attached
    Possible fix:
    Ext.data.TreeStore.onNodeRemove does this:
    PHP Code:
    if (!node.isReplace && Ext.Array.indexOf(removednode) == -1
        
    removed.push(node); 
    But perhaps it should check for phantom. I have no idea what "isReplace" is supposed to mean.
    PHP Code:
    if (!node.phantom && Ext.Array.indexOf(removednode) == -1
        
    removed.push(node); 
    Additional CSS used:
    • only default ext-all.css
    • custom css (include details)
    Related posts:
    Attached Files
    Last edited by emixion; 21 Jan 2013 at 6:03 AM. Reason: add related posts

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,074
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,917
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This isn't a bug.

    The record is not a phantom because you have explicitly given it an identifier. That is what indicates whether or not it's a phantom.

    As you've suggested, the current code reads:

    Code:
    isNotPhantom = record.phantom !== true;
    // don't push phantom records onto removed
    if (!isMove && isNotPhantom) {
        // ....
    }
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User
    Join Date
    Sep 2011
    Posts
    5
    Vote Rating
    1
    emixion is on a distinguished road

      0  

    Default


    Aha, how short sighted of me, sorry. I corrected it in the test case, but it still goes wrong. The remove function of Ext.data.Store does it's job correctly and skips the record. But the onNodeRemove handler of Ext.data.TreeStore still pushes the node onto the 'removed' list.
    Last edited by emixion; 21 Jan 2013 at 5:56 AM. Reason: also doesn't work without setting id

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Posts
    5
    Vote Rating
    1
    emixion is on a distinguished road

      0  

    Default temporary workaround

    temporary workaround


    PHP Code:
    Ext.define('CVB.data.TreeStore', {
        
    override'Ext.data.TreeStore'
        
        
    ,onNodeRemove: function(parentnodeisMove)
        {
            
    node.isReplace node.phantom;
            
    this.callParent([parentnodeisMove]);
        }
    }); 

Thread Participants: 2