PDA

View Full Version : Hi How can i connect to tree field and check this.Mytree.selModel.getSelections();



intro
11 Aug 2010, 5:32 PM
Here is big code :)

I am having a big problem geting data from tree panel, because i can not find how can i get data.
I think it is basic for any aplication maked with extj designer.

Tanks..

IzbornikAdmin = Ext.extend(IzbornikAdminUi, {
initComponent: function() {
IzbornikAdmin.superclass.initComponent.call(this);

var contextMenu = new Ext.menu.Menu({
items: [
{ text: 'Dodaj podizbornik'
},
{ text: 'Pregledaj podatke'
},
{
text: 'Delete',
handler:deleteHandler

}

]
});

function treeContextHandler(node) {
node.select();
contextMenu.show(node.ui.getAnchor());
};

this.Mytree.on('contextmenu', treeContextHandler); this is ok it is working
var editor = new Ext.tree.TreeEditor(this.Mytree);


editor.on('beforecomplete', function(editor, newValue, originalValue) {
Ext.Ajax.request({
url: 'izbornik_tree.php',
params: {
nodeid: editor.editNode.id,
newvalue: newValue,
task: "UPDATEEDIT"
}
});

});




// SORTIRANJE IZBORNIKA
this.Mytree.on('MouseOut' ,function(event){
console.log(HTMLElement.prototype.toString.call(event.relatedTarget));
});

this.Mytree.on('beforemovenode', function(tree, node,oldParent, newParent, index) {
Ext.Ajax.request({
url: 'izbornik_tree.php',
params: {
nodeid: node.id,
newparentid: newParent.id,
oldparentid: oldParent.id,
dropindex: index,
task: "UPDATETREE"
}
});
});



// BRISANJE IZBORNIKA

function deleteHandler() {
Ext.Msg.show({
title: 'IZBRIŠI PODATAK',
buttons: Ext.MessageBox.YESNOCANCEL,
msg: 'Sigurno želite obrisati podatak',
fn: function(btn){
if (btn == 'yes'){
scope: this;

when i try to connect i get error.
var selections = this.Mytree.selModel.getSelections();



Ext.Ajax.request({
url: 'izbornik_tree.php',
params: {id: selection.get('ID'),
task: "DELETETREE"
}
});
}
}
});
}






}

});

jarrednicholls
12 Aug 2010, 12:51 PM
Hi intro,

Can you do me a favor and (from now on) post your code inside of code tags (it is the # button on the forum post toolbar). It will preserve your code formatting. I honestly can't even read the code you posted :-) It sounds like the issue might be a scope problem or something thereof, but I cannot tell right now.

Sorry, Thanks!

intro
12 Aug 2010, 1:12 PM
Ok sorry for code...Thanks

jarrednicholls
12 Aug 2010, 1:19 PM
Hey Vladimir,

It's no worries, I want to help but I don't think all of the code is pasted above...and if it is then I am just having a hard time reading it. You can paste it once again or edit your post, just surround the code with the code tags [.code] and [/.code] without the "." dots before the word code. Thanks!

intro
13 Aug 2010, 3:37 AM
I found out how to connect..


function deleteHandler() {

var id= tree.getSelectionModel().getSelectedNode().id;
tree.getSelectionModel().getSelectedNode().remove();


Ext.Msg.show({
title: 'IZBRIŠI PODATAK',
buttons: Ext.MessageBox.YESNOCANCEL,
msg: 'Sigurno želite obrisati podatak',
fn: function(btn){
if (btn == 'yes'){



Ext.Ajax.request({
url: 'izbornik_tree.php',
params: {id: id,
task: "DELETETREE"
}
});
}
}
});
}

jarrednicholls
13 Aug 2010, 6:59 AM
Ah ok, terrific! Good work. Thanks for letting me know.