PDA

View Full Version : [Tree] - loading additional values for nodes



sunnywind
21 Sep 2007, 4:36 PM
Hello everyone :),

I'm using Ext tree in connection with forms, I'm able to save into database other fields than 'text', but I have problems with loading them, tree is loaded using:


var treest = new Tree.TreePanel('stbody', {
animate: true,
loader: new Tree.TreeLoader({
dataUrl:'action/isf/get-template.php'
}),
enableDD:true,
containerScroll: true
});

var stroot = new Tree.AsyncTreeNode({
text: TemplateName,
templateid: TemplateId,
templatename: TemplateName,
id: TemplateId,
draggable:false
});


After saving tree I've got values in database, but when each node is generated by loader which get json array with id, text, isfvalue, leaf, cls I receive only 'text' value in form generated by double click on tree element (see code below), when I replace in json array value of text to value of isfvalue then text have it... so I need to do smth to have passed other attributes than standard like 'text', 'leaf' etc via loader... I was looking for baseAttrs... but without efect - I will be very appreciated for any hint or better example :)




treest.on('dblclick', function(e){
ISFActionPERLCODE(e);
}

function ISFActionPERLCODE(e)
{
var dlg = new Ext.BasicDialog("my-dlg", {
height: 350,
width: 600,
title: 'Configure Element',
minHeight: 100,
minWidth: 450,
modal: true,
proxyDrag: true,
shadow: true
});

var simple = new Ext.form.Form({
labelWidth: 111
});

simple.add(
new Ext.form.TextField({
fieldLabel: 'Action',
name: 'action',
disabled: 'true',
value: e.text,
width:350
}),
new Ext.form.TextArea({
fieldLabel: 'Perl Code',
name: 'isfvalue',
value: e.isfvalue,
width:450,
height:150
})
);

simple.addButton('Information about element configuration', ISFActionPERLCODEHelp);
simple.addButton('Save', function() {
e.isfvalue = simple.findField('isfvalue').getValue();
dlg.hide();
});


simple.render(dlg.body);
dlg.addKeyListener(27, dlg.hide, dlg); // ESC can also close the dialog
dlg.show();
}

Thanks in advance
Sunnywind

BernardChhun
21 Sep 2007, 4:43 PM
just pass them in the JSON with cls, text and id dude :)


{id:"0", "text": "foo", cls : "bar", "whateverCustomProperty": "anything"}

you may then get them using


var newAttr = node.attributes.whateverCustomProperty;

sunnywind
21 Sep 2007, 4:54 PM
Hi

I'm back on the track after magical word "attributes" (I think it's too late now for me -> I've got 2:53 am here now)

Many Thanks Bernard :)