TB. treegrid tree list Asp.net Custom Controls

Source: Internet
Author: User

Controls written a long time ago are published inCodeplex. IncludingSource codeAnd demo. Here is the demo download, and we hope you can continue to improve it.

Supports ASP. net2.0, MS Ajax, PostBack, callback (available to load subnodes), event (select, expend, collaspe, rowcreate, rowdatabound, rowcommand), databind

The usage is similar to Treeview and gridview.

Display

Syntax:

 

Principle:

The main class of this control is similar to that of Ms Treeview, including three core classes: treegrid, treegridnode, and treegridrow. Treegridnode indicates a node and can have the dataitem attribute. treegridrow indicates the row of the node. Treegrid is of course the Tree Containing nodes. In addition, there are collection classes of treegridnode and treegridrow.

Different from Treeview, the presentation mode and view status management are different.

Treegrid uses the display method and syntax of the gridview, and controls the expansion and collapse of nodes on the client. A template must be defined for the presentation mode and syntax of the gridview. You can use JavaScript to control the expansion and collapse of client nodes.

Javascript
1 Function Treegrid_togglenode (data, index, toggleby, indicator, linetype, relation)
2 {
3 If ( ! Toggleby ){ Return ;}
4
5 VaR Nodetd = Webform_getparentbytagname (toggleby, " TD " ); // Get the TD of the node
6 If ( ! Nodetd ){ Return ;}
7 VaR Nodetr = Webform_getparentbytagname (nodetd, " Tr " ); // Obtain the TR of the node.
8 If ( ! Nodetr ){ Return ;}
9 VaR Noder = Treegrid_findnoderelationbynodeid (relation, nodetd. ID ); // Search for the relationship in relation based on TD. ID
10 If ( ! Noder ){ Return ;}
11
12 Treegrid_togglenodeexpandstate (nodetd, nodetr, noder );
13
14 VaR IMG = Indicator. childnodes [ 0 ];
15 VaR Newexpandstate;
16 Try {
17 If (Noder. e =   " E " ){
18 Newexpandstate =   " E " ;
19 If (( Typeof (IMG) ! =   " Undefined " ) && (IMG ! =   Null )){
20 If (Linetype =   " L " ){
21 IMG. SRC = Data. Images [ 15 ];
22 }
23 Else   If (Linetype =   " T " ){
24 IMG. SRC = Data. Images [ 12 ];
25 }
26 Else   If (Linetype =   " - " ){
27 IMG. SRC = Data. Images [ 18 ];
28 }
29 Else {
30 IMG. SRC = Data. Images [ 5 ];
31 }
32 IMG. ALT = Data. collapsetooltip. Replace ( / \ {0 \} / , "" );
33 }
34 }
35 Else {
36 Newexpandstate =   " C " ;
37 If (( Typeof (IMG) ! =   " Undefined " ) && (IMG ! =   Null )){
38 If (Linetype =   " L " ){
39 IMG. SRC = Data. Images [ 14 ];
40 }
41 Else   If (Linetype =   " T " ){
42 IMG. SRC = Data. Images [ 11 ];
43 }
44 Else   If (Linetype =   " - " ){
45 IMG. SRC = Data. Images [ 17 ];
46 }
47 Else {
48 IMG. SRC = Data. Images [ 4 ];
49 }
50 IMG. ALT = Data. expandtooltip. Replace ( / \ {0 \} / , "" );
51 }
52 }
53 }
54 Catch (E ){}
55 Data. expandstate. Value = Data. expandstate. value. substring ( 0 , Index) + Newexpandstate + Data. expandstate. value. Slice (Index +   1 );
56

 

View status management requires that the control load the view status based on the ID, instead of letting ASP. Net Load the view status information of the Control Based on the index of the Control tree on the page. This is because the control needs to use hierarchical traversal to load the view State.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.