dynamic dijit tree

hai
all those stuffs which i saw is just like static method of creating Dijit tree. so can you tel me ,the method for creating dynamic Dijit tree using context menu.
regards
tamy

Create dojo dijit.Tree dynamically

Hi,

I do not understand what do you mean by "creating dynamic Dijit tree using context menu" but probably this would help:

	// Dynamically create tree object
	<script type="text/javascript">
		dojo.addOnLoad(function(){
			// Create store
			var store = new dojo.data.ItemFileReadStore(
				{'url' : 'Inetpub/wwwroot/Dojo.0.9/dijit/tests/countries.json'});
			// Create tree
			var tree = new dijit.Tree({
					'labelAttr': 'name',
					'typeAttr': 'type',
					'store': store,
					'query': {type : 'continent'}
				}, dojo.byId('mytree2'));
		});
	</script>
	<div id="mytree2"></div>

Dynamic dijit tree

hai,
By using dojo 0.4 version, i used to create Tree as i have mentioned in these function,
function createtree()
{

var treeBasicController = dojo.widget.createWidget("TreeBasicController",{widgetId:"myTreeController",DNDController:"create"});
var treeselector = dojo.widget.createWidget("TreeSelector",
{widgetId:"treeSelector", eventNames:"select:nodeSelected"});
var treeEmp =dojo.widget.createWidget("TreeEmphasizeOnSelect",{ selector:"treeSelector"});
tree = dojo.widget.createWidget("Tree",
{widgetId:"tree",showGrid:false,showRootGrid:true,ActionsDisabled:"addChild",Controller:"treeController",
selector:"treeSelector",toggle:"plain", DNDMode:"between",Menu:"treeContextMenu",allowAddChildToLeaf:true});
var treeContainer = dojo.byId('treeview');
if (treeContainer)
treeContainer.appendChild(tree.domNode);
treeCreate(tree,treeBasicController);
}

function treeCreate(tree,treeBasicController)
{
treeNode = dojo.widget.createWidget("TreeNode",
{id:"Org",title:"Organization",isFolder: true, ActionsDisabled:"REMOVE",
menu:"GrpNodeMenu",Controller:treeBasicController.widgetId,tree:tree.widgetId,objectId:"1",onTitleClick:function(){}}); //packages
Dict.add(treeNode.id,treeNode)
treeNode.ActionsDisabled="Remove";
treeNode.Class ="dojoTreeNodeLabelTitle1";
tree.addChild(treeNode)
}

By creating context menu for this tree control, i used to add nodes in tree. i will call this function while loading my page , so that tree and root node wil be created initially.by clicking the root node,a context menu will appear,

Gnode = dojo.widget.createWidget("TreeNode",
{id:"Group_"+Gid,title:"Group_"+Gid, isFolder:true,
menu:"GrpNodeMenu",Controller:controller.widgetId,tree:tree.widgetId,objectId:"2"});
selectedNode.addChild(Gnode);
By using above syntax further nodes will be created dynamically.
Like this i need a proper method in dijit tree. can you help me ....

Tamy,

Tamy,

Please create and send me the HTML file that demonstrates the problem (my contact is here: http://www.alexatnet.com/node/18). I could not repeat the issue.

Thanks,
Alex

dijit tree

hai,
i think this comment will figure out my problem ... actually i want to create an empty Dijit tree, later on i have to add child nodes using my context menu's...
e.g:
if "Workspace " is a parent Node if user right clicks on that node , a context menu should appear,By clicking "add node" item from menu , a new node should be created under Workspace ..
can u help me how to achieve this...?

It is complex task

It seems like implementing this requires a lot of coding if there is no "official" solution.
You can review example from http://developer.yahoo.com/yui/examples/menu/treeviewcontextmenu_source.html to get the better understanding on how it can be done. If you can use YUI TreeVeiw, this example can be a good starting point.

Sincerely,
Alex

dynamic dijit tree

Hi,

from the Forum above. How can i create dynamic dijit tree without using URL parameter.

Thanks Alex.

Regards,
HKY