TreeView (Extension XmlselTree) (1)

zhaozj2021-02-16  55

TreeView (Expanding XMLseltree)

Visualsw

TreeView based on XML, JavaScript.

Reference http://61.163.246.155/pro/xmlseltree/ Thanks to the author of the XMLseltree program.

Add function: Right-click to add a delete node, save the Check status, expand all nodes, combine all nodes, and so on.

Rendering:

merge

Get XML to get the XML string of the tree structure

Right-click menu operation:

modify:

result

Added:

result

delete:

result:

achieve:

Treenode.xml structure is modified to:

Add Attribute: Checked Identification.

Download XMLSeltree, add the following code. / *

Function: Select information to HTML to select information to HTML.

Author: Shen Wang

* /

Function setischeck (S_HTML)

{

Var strreplace = "chK = /" true / "";

S_HTML = S_HTML.Replace (StrReplace, "Checked");

Strreplace = "chK = /" false / ";"

S_HTML = S_HTML.Replace (StrReplace, "");

Return S_HTML;

}

/ *

Modification: Shenwang

* /

/ *

Function: Expand all nodes

* /

Function expandall ()

{

m_oconfig.bexpand = true;

RecursionTree (m_oconfig.osrcdiv.children [0]);

}

/ *

Function: Collapse all nodes

* /

Function UNEXPANDALL ()

{

m_oconfig.bexpand = false ;;

RecursionTree (m_oconfig.osrcdiv.children [0]);

}

/ *

Function: Recursive all nodes

* /

Function RecursionTree (OBJ)

{

IF (Obj.children.Length == 0)

{

IF (Obj.tagname == "IMG")

{

IF (m_oconfig.bexpand)

{

IF (Obj.nameProp == "NodeImg1.gif")

{

MouseClick (OBJ);

}

}

Else

{

IF (Obj.nameProp == "NodeImg2.gif")

{

MouseClick (OBJ);

}

}

}

}

Else

{

Var i;

For (i = 0; i

{

RecursionTree (Obj.children [i]);

}

}

}

/ * New node * /

Function addNode (s_text, s_value)

{

VAR OXMLDOM = New ActiveXObject ("Microsoft.xmldom");

Oxmldom.async = false;

OxmlDom.LoadXml (Treexml);

Var rootnode = oxmldom.selectnodes ("/ root"). Item (0);

Readnode (Rootnode, S_Text, S_Value, "Add", Oxmldom;

Treexml = oxmldom.xml;

Window.onLoad ();

Expandall ();

}

/ * Modify node * /

Function ModifyNode (S_Text, S_Value)

{

VAR OXMLDOM = New ActiveXObject ("Microsoft.xmldom");

Oxmldom.async = false;

OxmlDom.LoadXml (Treexml);

Var rootnode = oxmldom.selectnodes ("/ root"). Item (0);

Readnode (Rootnode, S_Text, S_Value, "Modify");

Treexml = oxmldom.xml; window.onload ();

Expandall ();

}

/ * Delete node * /

Function deletenode (S_Text, S_Value)

{

VAR OXMLDOM = New ActiveXObject ("Microsoft.xmldom");

Oxmldom.async = false;

OxmlDom.LoadXml (Treexml);

Var rootnode = oxmldom.selectnodes ("/ root"). Item (0);

ReadNode (Rootnode, S_Text, S_Value, "Delete");

Treexml = oxmldom.xml;

Window.onLoad ();

Expandall ();

}

Function ReadNode (Element, S_Text, S_Value, Op, Oxmldom)

{

Element.haschildNodes)

{

IF (element.nodename == "treenode")

{

IF (("Title" == s_text) && (Element.getaTribute ("checkdata) == s_value))

{

Switch (OP)

{

Case "Add":

Var newNode = Oxmldom.createnode (1, "Treenode", "");

NewNode.setttribute ("Title", IPT_TITLE.VALUE);

NewNode.setttribute ("Checkdata", "000");

NewNode.setttribute ("CHK", "True");

Element.Appendchild (NewNode);

Break;

Case "modify":

Element.setttribute ("Title", IPT_TITLE.VALUE);

Element.setttribute ("CAPTION", IPT_CAPTION.VALUE);

Break;

Case "delete":

Element.parentNode.RemoveChild (Element);

Break;

DEFAULT:

Break;

}

}

}

Var i;

For (i = 0; i

{

IF (OP == "Add")

{

Readnode (Element.childNodes [i], s_text, s_value, op, oxmldom;

转载请注明原文地址:https://www.9cbs.com/read-25148.html

New Post(0)