• ASTreeView Demo:Add, Edit & Delete nodes


    http://www.jinweijie.com/

    http://www.astreeview.com/astreeviewdemo/astreeviewdemo1.aspx

    選擇節點:

    <script type="text/javascript">
    	    //選擇節點 OnNodeSelectedScript="nodeSelectHandler(elem);"
    		function nodeSelectHandler(elem){
    			var val = "selected node:" + elem.parentNode.getAttribute("treeNodeValue");
    			var vals=elem.parentNode.getAttribute("treeNodeValue");
    			var valt=elem.innerHTML;//獲取顯示的值//注:塗聚文
    			document.getElementById("<%=divConsole.ClientID %>").innerHTML 
    			+= (">>" + val + "<br />");
    			document.getElementById("<%=TextBox1.ClientID %>").value = vals;
    			document.getElementById("<%=TextBox2.ClientID %>").value = valt;
    		}
    		//parameter must be "elem"
    		function addedHandler( elem ){
    			document.getElementById( "<%=divConsole.ClientID %>" ).innerHTML 
    			+= ( ">>edit completed. [Node]" + elem.getAttribute("treeNodeValue") 
    			+ "<br />" );
    		}
    		
    		//parameter must be "elem"
    		function editedHandler( elem ){
    			document.getElementById( "<%=divConsole.ClientID %>" ).innerHTML 
    			+= ( ">>edit completed. [Node]" + elem.getAttribute("treeNodeValue") 
    			+ "<br />" );
    		}
    		
    		//parameter must be "val"
    		function deletedHandler( val ){
    			document.getElementById( "<%=divConsole.ClientID %>" ).innerHTML 
    			+= ( ">>delete completed. [Node]" + val
    			+ "<br />" );
    		}
    		
    		//elem is the LI element of each node
    		var displayNodeFunc = function( elem ){
    			document.getElementById( "<%=divConsole.ClientID %>" ).innerHTML 
    			+= ( ">>[Node]" + elem.getAttribute("treeNodeValue") 
    			+ " [Parent]:" + elem.parentNode.parentNode.getAttribute("treeNodeValue") 
    			+ " [CheckState]:" + elem.getAttribute("checkedState") 
    			+ "<br />" );	
    		}
    	</script>
    
    	<ct:ASTreeView ID="astvMyTree" 
    							runat="server"
    							BasePath="~/Javascript/astreeview/"
    							DataTableRootNodeValue="0"
    							EnableRoot="false" 
    							EnableNodeSelection="true" 
    							EnableCheckbox="false" 
    							EnableDragDrop="true" 
    							EnableTreeLines="true"
    							EnableNodeIcon="true"
    							EnableCustomizedNodeIcon="false"
    							AutoPostBack="false"
    							EnableDebugMode="false"
    							OnNodeSelectedScript="nodeSelectHandler(elem);"  
    							EnableContextMenu="true"
    							EnableAjaxOnEditDelete="true"
    							EditNodeProvider="~/ASTreeViewRenameNodeHandler.aspx"
    							DeleteNodeProvider="~/ASTreeViewDeleteNodeProvider.aspx"
    							AddNodeProvider="~/ASTreeViewDemo3.aspx"
    							AdditionalAddRequestParameters="{'t':'ajaxAdd'}"
    							AddNodePromptDefaultValue="New Node" 
    							AddNodePromptMessage="Hello, please add a new node:"
    							AddNodeDataValueProvider="return prompt('new ndoe? under:' + elem.getAttribute('treeNodeValue'),'new node name');"
    							OnNodeAddedScript="addedHandler(elem)"	
    							OnNodeEditedScript="editedHandler(elem)"
    							OnNodeDeletedScript="deletedHandler(val)" OnOnSelectedNodeChanged="astvMyTree_OnSelectedNodeChanged"  />
    
    		/// <summary>
    		/// initial controls, bind you events etc. here
    		/// </summary>
    		private void InitializeComponent()
    		{
                //獲取值 添加右鍵菜單進行編輯 //注:塗聚文
                //this.astvMyTree.ContextMenu.MenuItems.Add(new ASContextMenuItem("獲取 current value", "alert('current value:' + " + this.astvMyTree.ContextMenuClientID + ".getSelectedItem().parentNode.getAttribute('treeNodeValue')" + ");return false;", "otherevent"));
                this.astvMyTree.ContextMenu.MenuItems.Add(new ASContextMenuItem("獲取 current value", "alert('current value:' + " + this.astvMyTree.ContextMenuClientID + ".getSelectedItem().parentNode.getAttribute('treeNodeValue')" + ");window.location.href ='ASTreeViewEdit.aspx?EditNodeValues='+" + this.astvMyTree.ContextMenuClientID + ".getSelectedItem().parentNode.getAttribute('treeNodeValue')" + ";", "otherevent"));
                this.astvMyTree.ContextMenu.MenuItems.Add(new ASContextMenuItem("獲取 current text", "alert('current text:' + " + this.astvMyTree.ContextMenuClientID + ".getSelectedItem().innerHTML" + ");return false;", "otherevent"));
    		}
    
  • 相关阅读:
    微软经典项目实例
    Extjs在vs中使用及弹出对话框的介绍
    微软企业库5.0学习笔记(七)
    微软企业库5.0学习笔记(八)
    微软企业库5.0学习笔记(十)
    .NET 4 并行(多核)编程系列之五
    NET 应用架构指导 V2[12]
    .NET 4 并行(多核)编程系列之四
    .NET 4 并行(多核)编程系列之三
    微软企业库5.0学习笔记(十二)
  • 原文地址:https://www.cnblogs.com/geovindu/p/3546401.html
Copyright © 2020-2023  润新知