Explorar el Código

fixed: for PopulateOnDemand nodes expanded and checked state restored correct on PostBack

svn path=/trunk/mcs/; revision=65153
Igor Zelmanovich hace 19 años
padre
commit
fd2f5e65bd

+ 6 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2006-09-10 Igor Zelmanovich <[email protected]>
+
+	* TreeView.cs: fixed: for PopulateOnDemand nodes expanded and checked 
+	state restored correct on PostBack.
+	* TreeView.js	
+
 2006-09-08 Gonzalo Paniagua Javier <[email protected]>
 
 	* ObjectDataSourceView.cs: correctly find the type when it is not in the

+ 18 - 0
mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs

@@ -927,6 +927,20 @@ namespace System.Web.UI.WebControls
 		{
 			bool res = false;
 
+			if (PopulateNodesFromClient) {
+				string states = postCollection [ClientID + "_PopulatedStates"];
+				if (states != null) {
+					foreach (string id in states.Split ('|')) {
+						if (String.IsNullOrEmpty(id))
+							continue;
+						TreeNode node = FindNodeByPos (id);
+						if (node != null && node.PopulateOnDemand && !node.Populated)
+							node.Populate();
+					}
+				}
+				res = true;
+			}
+
 			if (ShowCheckBoxes != TreeNodeTypes.None) {
 				UnsetCheckStates (Nodes, postCollection);
 				SetCheckStates (postCollection);
@@ -1005,6 +1019,10 @@ namespace System.Web.UI.WebControls
 					Page.ClientScript.GetCallbackEventReference (this, "null", "", "null");
 					Page.ClientScript.GetPostBackClientHyperlink (this, "");
 				}
+
+				if (PopulateNodesFromClient) {
+					Page.ClientScript.RegisterHiddenField (ClientID + "_PopulatedStates", "|");
+				}
 			}
 		}
 

+ 1 - 0
mcs/class/System.Web/System.Web.UI.WebControls/TreeView.js

@@ -61,6 +61,7 @@ function TreeView_PopulateCallback (data, ids)
 		}
 	}
 	TreeView_ToggleExpand (idArray[0], idArray[1]);
+	TreeView_SetNodeFlag (document.forms[0][idArray[0] + "_PopulatedStates"], idArray[1], true);
 }
 
 function TreeView_ErrorCallback (data, ids)