protected void TreeView1_GetNodeData(object sender, GetNodeDataEventArgs e) { if (e.Node.Name[0] == '_') { return; } if (m_nodes == null) { // 首次初始化 m_nodes = GetParentNodes(e.Node.OwnerDocument.DocumentElement, this.TreeView1.SelectedNodePath); } string strName = DomUtil.GetAttr(e.Node, "name"); if (string.IsNullOrEmpty(strName) == true) { return; } string strDate = DomUtil.GetAttr(e.Node, "date"); // string strDataFile = Path.GetFileName(this.TreeView1.XmlFileName).ToLower(); e.Name = strName; if (strDate == this.TreeView1.SelectedNodePath) { e.Seletected = true; } /* * string strDateParam = ""; * if (string.IsNullOrEmpty(strDate) == false) * strDateParam = "&date=" + HttpUtility.UrlEncode(strDate); * * e.Url = "./statischart.aspx?" + strDateParam; * */ e.Url = strDate; // if (e.Node == e.Node.OwnerDocument.DocumentElement) if (this.m_nodes != null && this.m_nodes.Count > 0) { if (this.m_nodes.IndexOf(e.Node) != -1) { e.Closed = false; } } else { e.Closed = false; } }
protected void TreeView1_GetNodeData(object sender, GetNodeDataEventArgs e) { /* * if (e.Node == e.Node.OwnerDocument.DocumentElement) * return; * */ if (e.Node.Name[0] == '_') { return; } string strName = DomUtil.GetAttr(e.Node, "name"); if (string.IsNullOrEmpty(strName) == true) { return; } bool bCommand = true; string strCommand = DomUtil.GetAttr(e.Node, "command"); if (string.IsNullOrEmpty(strCommand) == false && strCommand[0] == '~') { bCommand = false; } /// string strSideBarFileName = Path.GetFileName(this.SideBarControl1.CfgFile).ToLower(); string strDataFile = Path.GetFileName(this.TreeView1.XmlFileName).ToLower(); string strNodePath = CacheBuilder.MakeNodePath(e.Node); string strCount = ""; if (bCommand == true) { strCount = app.GetBrowseNodeCount(strDataFile, strNodePath); if (string.IsNullOrEmpty(strCount) == true && app.CacheBuilder != null) { long lCount = app.CacheBuilder.GetCountByNodePath(strDataFile, strNodePath, false); if (lCount == -1) { strCount = "?"; } else { strCount = lCount.ToString(); } app.SetBrowseNodeCount(strDataFile, strNodePath, strCount); } } if (string.IsNullOrEmpty(strCount) == false) { // e.Name = strName + " (" + strCount + ")"; e.Name = strName; e.Count = strCount; } else { e.Name = strName; } if (strNodePath == this.SelectingNodePath) { e.Seletected = true; /* * // 如果有更适合的标题文字 * if (string.IsNullOrEmpty(this.SelectedNodeCaption) == false) * e.Name = this.SelectedNodeCaption; * */ } // TODO: 是否可以给每个节点都显示包含记录的数字? 为了提高速度,是否可以用一个hashtable来存储这个数字对照关系? string strSideBarParam = ""; if (string.IsNullOrEmpty(strSideBarFileName) == false) { strSideBarParam = "&sidebar=" + HttpUtility.UrlEncode(strSideBarFileName); } string strFormatParam = ""; if (string.IsNullOrEmpty(this.BrowseSearchResultControl1.CurrentFormat) == false) { strFormatParam = "&format=" + HttpUtility.UrlEncode(this.BrowseSearchResultControl1.CurrentFormat); } else if (string.IsNullOrEmpty(this.BrowseSearchResultControl1.FormatName) == false) { strFormatParam = "&format=" + HttpUtility.UrlEncode(this.BrowseSearchResultControl1.FormatName); } e.Url = "./browse.aspx?datafile=" + HttpUtility.UrlEncode(strDataFile) + strSideBarParam + "&node=" + strNodePath + strFormatParam; if (e.Node == e.Node.OwnerDocument.DocumentElement || IsParentPath(strNodePath, this.SelectingNodePath) == true) { e.Closed = false; } }