PDA

View Full Version : TreeStore. Remove node. url is undefined. ExtJS 4.1.1.



Eugent
17 Jul 2012, 11:36 PM
Hello, in my project i use tree with treeStore. When i am trying to remove node occure error "url is undefined". I use ExtJS 4.1.1.

Code of store:


Ext.define('App.model.Tree', {
extend: 'Ext.data.Model',
fields: [
{name: 'text', type: 'string', mapping: 'text'},
{name: 'leaf', type: 'boolean', mapping: 'leaf'},
{name: 'branch_id', type: 'int', mapping: 'branch_id'}
]
});

Ext.create('Ext.data.TreeStore', {
model: 'App.model.Tree',

folderSort: true,
sorters: [{
property: 'text',
direction: 'ASC'
}],

model : model_label,

proxy : {
type: 'ajax',
url: '/tree/list',
actionMethods: {
read : 'POST'
},
reader: {
type: 'json',
root: 'data'
}
},
root : {
text : 'Root',
label : 'root',
expanded: false,
branch_id: 0
}
});


Code of button to delete node:


var region_panel = th_but.up('treepanel');
if(region_panel){
var store = region_panel.getStore(),
sm = region_panel.getSelectionModel(),
has_selection = sm.hasSelection();

if(has_selection){
var selected = sm.getSelection()[0];
selected.destroy();
}
}


How i must to remove node from tree without errors?

tvanzoelen
18 Jul 2012, 1:07 AM
What if you do this?



selected.remove(true, true);

Eugent
18 Jul 2012, 1:23 AM
What if you do this?



selected.remove(true, true);


url is undefined
http://app.local/js/frameworks/ext_4_1_1/ext-all-debug-w-comments.js (http://webgarant.as.local/js/frameworks/ext_4_1_1/ext-all-debug-w-comments.js)
Line 1241

sword-it
18 Jul 2012, 3:24 AM
Hi,

you can check this link http://extjstutorial.info/extjs-4-tutorial-delete-extjs-tree-node-dynamically/124

Eugent
23 Jul 2012, 5:22 AM
Ajax is easier to do - and after a request to update the parentNode