I
----- Treeview first revision -------
1. Target: By triggering the expansion event of level 0 nodes, only all level 1 subnodes under this node are loaded, And the subnodes of level 0 nodes that are not triggered do not need to be loaded.
2. Implementation: each node has a plus sign. clicking the plus sign triggers the node expansion event TV _treenodeexpanded to load the data of the subnodes under this node.
3. Limitations: When only the level 0 node is displayed for the first time (NO Level 1 subnode is available), no plus sign exists before the data displayed by the Treeview control.
Node expansion event.
4. Solve the preceding limitations (how to have a plus sign before the node ):
1. Preliminary solution: When the 0-level node is displayed, all the 1-level nodes are loaded. The main purpose is to have a plus sign in front of it,
Trigger node expansion events
2. First improvement:
1. Previous problem: As Step 1 above adds a full level of data (for example, when a page is loaded,
To have a plus sign, you need to load the level 1 subnodes of all level 0 nodes. In fact, you only need to know all level 0 nodes.
Similarly, when you click a level 0 node, all Level 2 subnodes under the node will be loaded. In fact, only Level 1 nodes under the node are required.
2. Major improvement: this is mainly a performance improvement. There is no way to break through, or when loading pages, load all level 0 nodes and Level 1 nodes
Only when a level 1 node is loaded, only one piece of data is loaded. That is, when a page is loaded for the first time, all levels 0 nodes and
"One" Level 1 node. When you click a level 0 node, first clear the subnodes under this node, and then load all level 1 nodes and each level 1 Node
"One" Level 2 node, where "one" is enclosed in quotation marks, indicating that the user does not need to see the node and only queries one piece of data. For example, the user clicks Hubei
Province: load all cities in Hubei province, and load a zone under each city (only one zone is loaded under each city, rather than all the zones under the city)
3. Second improvement: the breakthrough in methods was suddenly remembered when the document was written here.
When a page is loaded, all the zero-level nodes are loaded with "one piece" of data under each zero-level node at the same time (this data can be arbitrary, not necessarily from the number
For database query, node. childnodes. Add (New treenode (); in this way, a plus sign is added each time a node of level 0 is loaded,
At the same time, I don't need to read Level 1 nodes from the database.) This is indeed an exciting news for me.
5. problem: the second improvement mentioned above has a problem: If there are no subnodes under the node, there will also be a plus sign in front, which may confuse the user
II
--------- Treeview part of the second revision ---------
1. The third improvement (this time the data query is replaced with the Stored Procedure ):
Purpose: when loading a page, if a subnode under level 0 has a plus sign in front of it, and if no subnode exists, there is no plus sign.
Implementation: based on the previous improvement, add a judgment. Originally, when loading a page, load all level 0 subnodes and load each level 0 Node
"One piece of data, now add a judgment before loading" one piece of data, whether this level 0 node has a subnode.
2. problems and to be improved:
1. The third improvement is compared with the second one. In fact, conditional judgment is added to the traversal, and the database is queried once more for each traversal,
I don't know how much impact it will have on performance, especially when performing traversal by adding conditions, I feel it will affect performance.
2. This data does not have an auto-growth column. It should be okay if I add an auto-growth column.
3. I think the function for adding a root node is similar to that for adding a child node. I want to bring them together.
4. When a node is clicked, the child node is cleared and then loaded. This is not good. I only want to clear the child node when the node is triggered for the first time.
Sub-nodes, which can be retained later, not cleared or reloaded
Iii. key code:
1. When the page is loaded, load all the 0-level nodes, and load "one piece" of data under each 0-level node. Determine whether a subnode exists before loading.
Dataset sub_ds = getdataset ("sp_searchsinglerecord", convert. toint32 (childnode. Value ));
If (sub_ds.tables [0]. Rows. Count! = 0)
{
// Load "one" Level 1 Node
Childnode. childnodes. Add (New treenode ());
}