While using TreeView and set PopulateNodesFromClient=true, I expect that the children of a node being expanded immedately after populated. but currently it needs twice click on the '+' sign of the node. first click is to 'TreeView_PopulateNode' and then
second click is able to 'TreeView_ToggleNode' .
I traced the javascript code and found the problem occured in 'TreeView_ProcessNodeData'. while the newchildren is created, the ''TreeView_ToggleNode' is in fact called immedately. but because the style.display of newchildren is initialized with empty ('')
, and then 'TreeView_ToggleNode' will change its display to 'none'.
if set style.display of newchildren to 'none' after it is initially created, 'TreeView_ToggleNode' will change it to 'block'.
Hope Microsoft check this issue and correct the possible bug (Just insert code to set style.display of newchildren to 'none' before 'TreeView_ToggleNode' it ).
function TreeView_ProcessNodeData(result, context) {
//code here is omitted
if ((typeof(newChildren) != "undefined") && (newChildren != null)) {
// initialize style.display to 'none' here can resolve this problem
TreeView_ToggleNode(context.data, context.index, treeNode, context.lineType, newChildren);
treeNode.href = document.getElementById ?
"javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + ",document.getElementById('" + treeNode.id + "'),'" + context.lineType + "',document.getElementById('" + newChildren.id + "'))" :
"javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + "," + treeNode.id + ",'" + context.lineType + "'," + newChildren.id + ")";
if ((typeof(context.selectNode) != "undefined") && (context.selectNode != null) && context.selectNode.href &&
(context.selectNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) {
context.selectNode.href = treeNode.href;
}
if ((typeof(context.selectImageNode) != "undefined") && (context.selectImageNode != null) && context.selectNode.href &&
(context.selectImageNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) {
context.selectImageNode.href = treeNode.href;
}
}
context.data.populateLog.value += context.index + ",";
}
else {
var img = treeNode.childNodes ? treeNode.childNodes[0] : treeNode.children[0];
if ((typeof(img) != "undefined") && (img != null)) {
var lineType = context.lineType;
if (lineType == "l") {
img.src = context.data.images[13];
}
else if (lineType == "t") {
img.src = context.data.images[10];
}
else if (lineType == "-") {
img.src = context.data.images[16];
}
else {
img.src = context.data.images[3];
}
var pe;
if (__nonMSDOMBrowser) {
pe = treeNode.parentNode;
pe.insertBefore(img, treeNode);
pe.removeChild(treeNode);
}
else {
pe = treeNode.parentElement;
treeNode.style.visibility="hidden";
treeNode.style.display="none";
pe.insertAdjacentElement("afterBegin", img);
}
}
}
}
carlsjf
None
0 Points
15 Posts
Bug With TreeView_ProcessNodeData?
Mar 13, 2010 03:38 PM|LINK
While using TreeView and set PopulateNodesFromClient=true, I expect that the children of a node being expanded immedately after populated. but currently it needs twice click on the '+' sign of the node. first click is to 'TreeView_PopulateNode' and then second click is able to 'TreeView_ToggleNode' .
I traced the javascript code and found the problem occured in 'TreeView_ProcessNodeData'. while the newchildren is created, the ''TreeView_ToggleNode' is in fact called immedately. but because the style.display of newchildren is initialized with empty ('') , and then 'TreeView_ToggleNode' will change its display to 'none'.
if set style.display of newchildren to 'none' after it is initially created, 'TreeView_ToggleNode' will change it to 'block'.
Hope Microsoft check this issue and correct the possible bug (Just insert code to set style.display of newchildren to 'none' before 'TreeView_ToggleNode' it ).
function TreeView_ProcessNodeData(result, context) { //code here is omitted if ((typeof(newChildren) != "undefined") && (newChildren != null)) { // initialize style.display to 'none' here can resolve this problem TreeView_ToggleNode(context.data, context.index, treeNode, context.lineType, newChildren); treeNode.href = document.getElementById ? "javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + ",document.getElementById('" + treeNode.id + "'),'" + context.lineType + "',document.getElementById('" + newChildren.id + "'))" : "javascript:TreeView_ToggleNode(" + context.data.name + "," + context.index + "," + treeNode.id + ",'" + context.lineType + "'," + newChildren.id + ")"; if ((typeof(context.selectNode) != "undefined") && (context.selectNode != null) && context.selectNode.href && (context.selectNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) { context.selectNode.href = treeNode.href; } if ((typeof(context.selectImageNode) != "undefined") && (context.selectImageNode != null) && context.selectNode.href && (context.selectImageNode.href.indexOf("javascript:TreeView_PopulateNode", 0) == 0)) { context.selectImageNode.href = treeNode.href; } } context.data.populateLog.value += context.index + ","; } else { var img = treeNode.childNodes ? treeNode.childNodes[0] : treeNode.children[0]; if ((typeof(img) != "undefined") && (img != null)) { var lineType = context.lineType; if (lineType == "l") { img.src = context.data.images[13]; } else if (lineType == "t") { img.src = context.data.images[10]; } else if (lineType == "-") { img.src = context.data.images[16]; } else { img.src = context.data.images[3]; } var pe; if (__nonMSDOMBrowser) { pe = treeNode.parentNode; pe.insertBefore(img, treeNode); pe.removeChild(treeNode); } else { pe = treeNode.parentElement; treeNode.style.visibility="hidden"; treeNode.style.display="none"; pe.insertAdjacentElement("afterBegin", img); } } } }TreeView ProcessNodeData ToggleNode
carlsjf
None
0 Points
15 Posts
Re: Bug With TreeView_ProcessNodeData?
Mar 14, 2010 03:04 PM|LINK
I got it.
after I populate a node, I set PNode.Expanded = true. It is not necessary.
I set it to true and the treeview toggle it back to collapse.
Thanks!
carlsjf
None
0 Points
15 Posts
Re: Bug With TreeView_ProcessNodeData?
Mar 14, 2010 03:15 PM|LINK
I got it.
I have a mistake. while I populate a node, I set its expand to 'true' and treeview toggle it back to collapse.
after i remove 'PNode.Expand=true;', it works normally.
Thanks!