-
18 Jan 2013 4:20 AM #1
TreeStore sends DELETE request for phantom nodes
TreeStore sends DELETE request for phantom nodes
REQUIRED INFORMATION
Ext version tested:- Ext 4.1.1
- Chrome 25
- HTML
- A DELETE request is sent for phantom nodes (nodes not known remotely yet) on manual sync.
- 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
- Not any HTTP request
- A DELETE HTTP request for the new node
HELPFUL INFORMATIONPHP Code:// define the REST store
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'rest',
url: 'test-nodes.json',
appendId: false,
reader: {type: 'json', root: 'data'},
writer: {type: 'json'}
}
,root: {
text: 'root',
id: 'root-1',
expanded: true
}
});
// create the tree
var tree = Ext.create('Ext.tree.Panel', {
store: store
,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
Testcase:- attached
Ext.data.TreeStore.onNodeRemove does this:
But perhaps it should check for phantom. I have no idea what "isReplace" is supposed to mean.PHP Code:if (!node.isReplace && Ext.Array.indexOf(removed, node) == -1)
removed.push(node);
Additional CSS used:PHP Code:if (!node.phantom && Ext.Array.indexOf(removed, node) == -1)
removed.push(node);
- only default ext-all.css
- custom css (include details)
Last edited by emixion; 21 Jan 2013 at 6:03 AM. Reason: add related posts
-
18 Jan 2013 4:34 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,117
- Vote Rating
- 453
Thanks for the report! I have opened a bug in our bug tracker.
-
20 Jan 2013 5:15 PM #3
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!
-
21 Jan 2013 5:16 AM #4
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
-
4 Feb 2013 5:04 AM #5
temporary workaround
temporary workaround
PHP Code:Ext.define('CVB.data.TreeStore', {
override: 'Ext.data.TreeStore'
,onNodeRemove: function(parent, node, isMove)
{
node.isReplace = node.phantom;
this.callParent([parent, node, isMove]);
}
});
You found a bug! We've classified it as
EXTJSIV-8267
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote