cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to fill XUI Treecontrol

dgopois
12-Amethyst

How to fill XUI Treecontrol

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

1 ACCEPTED SOLUTION

Accepted Solutions

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 &lt;= 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. 😉

View solution in original post

2 REPLIES 2

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 &lt;= 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

Top Tags