| Page 1 of 1 | [ 5 posts ] |
|
Hi,
I have used Treeview Node Selection and Checkbox with database connection. The program works if some one checks the root then the subroot is selected. After selecting the root name, when the user selects any subroot value automaticlly main root value should change to (-) symbol, but this form is not working in the program. Could any one help me out what is an error of my program. I have pasted the program below. Thanks for your help. YAHOO.example.treeExample = function() { function buildTree() { //create a new tree: tree = new YAHOO.widget.TreeView("treeContainer"); //get root node for tree: var root = tree.getRoot(); //create data for root var a = ["example1","ex2","ex3"]; for (i=0;i<a.length;i++) { var tmpNode = new YAHOO.widget.TextNode({label: a[i], customData: a[i] + "-metadata"}, root, false); //set dynamic loading just for these top-level nodes tmpNode.setDynamicLoad(loadNodeData); tree.setNodesProperty('propagateHighlightUp',true); tree.setNodesProperty('propagateHighlightDown',true); tree.subscribe('clickEvent',tree.onEventToggleHighlight); tree.render(); } YAHOO.util.Event.on('logHilit','click',function() { var hiLit = tree.getNodesByProperty('highlightState',1); if (YAHOO.lang.isNull(hiLit)) { alert("None selected"); } else { var labels = []; for (var i = 0; i < hiLit.length; i++) { labels.push(hiLit[i].label); } var resultnode = labels; Getnodes(resultnode); //alert("Selected nodes:\n" + labels.join("\n"), "info", "example"); //YAHOO.log("Highlighted nodes:\n" + labels.join("\n"), "info", "example"); } }); //tree.draw(); } return { init: function() { buildTree(); } }; } (); //handler to process label clicks, to be //assigned in our dynamic load function function loadNodeData(node, fnLoadComplete) { var oResults =[]; var a = new Array(); var sUrl = "tree.do?treename="+ node.label; var callback = { success: function(oResponse) { YAHOO.log("XHR transaction was successful.","info", "example"); oResults = YAHOO.lang.JSON.parse(oResponse.responseText); for (var i=0, j=oResults.bookorders.length; i<j; i++) { var tempNode = new YAHOO.widget.TextNode(oResults.bookorders[i].assaykey, node, false); fnLoadComplete(); } }, failure: function(oResponse) { YAHOO.log("Failed to process XHR transaction.", "info", "example"); oResponse.argument.fnLoadComplete(); }, argument: { "node": node, "fnLoadComplete": fnLoadComplete }, timeout: 7000 }; YAHOO.util.Connect.asyncRequest('POST', sUrl, callback); } YAHOO.util.Event.addListener(window, "load", YAHOO.example.treeExample.init, YAHOO.example.treeExample, true); |
|
It is very hard to read code without formatting. Besides, I believe there is code besides the point, there seems to be a section devoted to logging which is a waste of time for me to figure out it doesn't belong there. Please use pastebin or gist to paste code or better yet, jsfiddle.net to provide an example that works on its own.
A few things I did notice, though is that you are calling fnLoadComplete on every node you add to the tree. This is not correct, it should be called once all the nodes have been added, not inside a loop. Second, you are very specifically setting the propagate and dynamic loading properties just on the first nodes. There is no reason why the new added nodes would respond to highlighting when you have specifically excluded them. Finally, I don't see why selecting a child should affect the [+] or [-] icon on the parent, but I'm probably missing something. Anyway, perhaps I got lucky and hit something with my suggestions above. |
|
Hi ,
Thanks for your comments. I am very new to this forum and begginner in the programming. I have changed the codes which you have speicified but still the problem did not get solved. Can you check .. The problem is, while selecting the parent node's checkbox, all the child nodes is selected. in the same way if any one child is unchecked then parents node's CHECKBOX should change to [-] but that is not happening. still the parent node is checked. There is no problem in the tree structure [+] and [-]. Only problem is in Checkbox. http://pastebin.com/xFsxG6EE i used this http://developer.yahoo.com/yui/examples/treeview/tv_highlight_clean.html example . Thanks. |
|
Ok, now I undestand. The problem is that while you are specifically setting the propagation of the initial nodes, you are not doing the same on the new nodes you add dynamically. If you don't tell those nodes to propagate their highlight state upwards, the parent nodes will never take note.
The setNodesProperty method only affects the nodes that exist at the time it is called. So, once you create those sets of new nodes, you should do tempNode.propagateHighlightUp = true; to set that property on the new nodes. BTW, the first nodes have no nodes up to propagate their state. It doesn't hurt, it is just pointless. |
|
Hi,
Thanks a lot!!!! I got it. I have added the line loadnodedata Code: tempNode.propagateHighlightUp = true; Its working now.. Thanks once again. |
| Page 1 of 1 | [ 5 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group