12
Answers

Warning: I lost a post

Sam Hobbs

Sam Hobbs

14y
2k
1
I typed a reply and then got distracted a few minutes and then finished the reply and clicled the Post button and then I looked around at something else and then when I looked back I saw a message saying that at post cannot be blank and everything I had typed was gone. I am not sure what happened but there might be a problem with the forum software. To avoid possible loss of data, copy your post to the clipboard before posting then wait and ensure that it is successful. If the problem happens to you then post here.
Answers (12)
Hi Hemant,
CoolJSTree is bit different. To get the file element from javascript, the tree should expand atleast once.. The span / anchor tags are rendered only on expand option. So I made expand all on tree load. Whenever you try to search some file, the tree will collapse and expand only the result tree hierarchy. Here is my code.. I have tried "PIP", it works fine..  Please let me know if you need any clarifications.
 
 
<script>
alert('started in index.jsp');
var tree1 = new COOLjsTree("tree1", TREE_NODES, TREE_FORMAT);
tree1.expandAll();
alert('ended in index.jsp');
$(function() {
$('#submit').on('click', function() {
tree1.collapseAll();
var results = $("a.treeNode[href^='download_documents.jsp']:contains('" + $('#search').val() + "')");
if (results.length == 0) {
alert("file not found!");
return false;
}
var targetElement = $(results[0]);
var targetAnchor = targetElement.is("span") ? $(targetElement.parent()[0]) : targetElement;
var targetUrl = targetAnchor.attr('href').replace(targetAnchor[0].protocol + '//' + targetAnchor[0].host, "");
var targetNodeIndex = tree1.nodeByURL(targetUrl).index;
var node = tree1.nodeByIndex(targetNodeIndex);
var expandList = [];
while (node.parentNode != null && node.parentNode.index > -1) {
if (!node.parentNode.expanded) expandList.push(node.parentNode.index);
node = node.parentNode;
}
expandList.reverse();
$.each(expandList, function(index, v) {
tree1.expandNode(v, true, true);
});
tree1.draw();
return false;
});
});
</script> 
0
hemant kumar

hemant kumar

NA 32 59.5k 9y

Attachment expandtrre.zip

hii harish
i have attached my source code please go through. set start page as newtree.aspx and see .
 
Can you share the code which you wrote for treeview display. so that we can try for search functionality...