Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello,
I have created an XUI dialog box with a tree control. I would like to know how to fill a tree control with ACL code.
I want to fill the treecontrol with an xml node (and child nodes).
David
Solved! Go to Solution.
You will need to generate the <treenode> elements and append them to the <treecontrol> in your code. I don't have ACL code for this, but here's an example that uses Javascript to walk the doc structure recursively and build a tree:
// walks the document and creates a corresponding tree structure in the dialog
function populateTree(branch,oid) {
var doc = branch.ownerDocument;
var newbranch = doc.createElement("treenode");
newbranch.setAttribute("label",Acl.eval("oid_name('" + oid + "')"));
newbranch.setAttribute("appdata",oid);
newbranch.setAttribute("id",oid_xmlname(oid));
var nkids = Acl.eval("oid_children('" + oid + "')");
for (var i=1; (i <= nkids); i++) {
populateTree(newbranch,Acl.eval("oid_child('" + oid + "'," + i + ")"));
}
branch.appendChild(newbranch);
}
// converts an oid to a valid XML name string
function oid_xmlname(oid) {
var name = oid.replace("(","").replace(")","").replace(",",".").replace(",",".");
return "_" + name;
}
Conversion to ACL (if needed) is left as an exercise for the reader. 😉
You will need to generate the <treenode> elements and append them to the <treecontrol> in your code. I don't have ACL code for this, but here's an example that uses Javascript to walk the doc structure recursively and build a tree:
// walks the document and creates a corresponding tree structure in the dialog
function populateTree(branch,oid) {
var doc = branch.ownerDocument;
var newbranch = doc.createElement("treenode");
newbranch.setAttribute("label",Acl.eval("oid_name('" + oid + "')"));
newbranch.setAttribute("appdata",oid);
newbranch.setAttribute("id",oid_xmlname(oid));
var nkids = Acl.eval("oid_children('" + oid + "')");
for (var i=1; (i <= nkids); i++) {
populateTree(newbranch,Acl.eval("oid_child('" + oid + "'," + i + ")"));
}
branch.appendChild(newbranch);
}
// converts an oid to a valid XML name string
function oid_xmlname(oid) {
var name = oid.replace("(","").replace(")","").replace(",",".").replace(",",".");
return "_" + name;
}
Conversion to ACL (if needed) is left as an exercise for the reader. 😉
Hello,
Thanks for your response.
Maybe the code in the file "C:\Program Files\PTC\Arbortext Editor\packages\tools\_applicability_dlg.acl" can also help.
David