Use Tree Picker in UI Page

Kenny Gosai1
Tera Contributor

Hello, 

 

I am trying to utilize the tree picker tool with a UI page I am creating. I am trying to list groups and have users in each group as the child component. I tried to utilize GwtTree2 and it seems to display the groups correctly but does not expand correctly to show the users in each group. I have tried using different processors but can't seem to get it to expand correctly.

 

Is it possible to list the groups and users using tree picker? Thank you for your time and help.

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <link href="styles/gwt.cssx" type="text/css" rel="stylesheet"/>

    <g:requires name="gwt_tree2.js"/>
    <g:requires name="scripts/classes/CITree2Node.jsx"/>
    <g:requires name="SCTreeNode.js"/>
    <g:requires name="scripts/classes/TableTreeNode.js"/>
   
    <div id="big_tree"></div>
    <script>
        var t = new GwtTree2("big_tree", "big_tree");
        t.xmlItemNodeName = "item";
        t.showRootNode = true;
       
        var rootNode = new GwtTree2Node(t, "", "Testing");
rootNode.processedChildren = true;
rootNode.show();

var ciNode = new CITree2Node(rootNode, "", "Groups");
ciNode.processor = "FunctionTreeData";
ciNode.setText("User Groups");
rootNode.appendChild(ciNode);
addBusinessServiceNodes(ciNode);

function addBusinessServiceNodes(ciNode) {
// var gr = new GlideRecord('cmdb_ci_service');
var gr = new GlideRecord('sys_user_group');
gr.addOrderBy('name');
gr.query();
while (gr.next()) {
var bsNode = new CITree2Node(ciNode, gr.sys_id + '');
bsNode.sys_id = gr.sys_id + '';
bsNode.setText(gr.name);
bsNode.setTable('sys_user_group');
bsNode.setParentName('parent');
bsNode.setChildName('child');
ciNode.appendChild(bsNode);
}
ciNode.collapse();
}

     </script>


</j:jelly>
2 REPLIES 2

Neha_Gupta
Tera Contributor

Hi Kenny,

Did you get any solution for this issue. I am also trying to use GwtTree2 but its not working properly.

Juan Miguel
Tera Expert

Hi, this is the code used in the ScriptTableTree.js file to create a tree of scripts, maybe can help: 

initialize: function(treeName, element, table, target, includeFunctions) {
		GwtTree2.prototype.initialize.call(this, treeName, element);
        this.xmlItemNodeName = "item";
        this.showRootNode = false;
		
		this.tableName = table;
		this.target = target;
		this.treeElement= element;
		this.includeFunctions = includeFunctions;
		
this.email = false;
this.syntaxEditor = false;
		this.tinymce = false;
		
		this.fieldMsg = getMessage("uppercase_fields");
	},