Asp.net repeater implements tree Scaling

Source: Internet
Author: User

First look:

This is implemented on the basis of dtcms, because there are too many classifications and need to be scaled up,

In fact, there are still many problems with this instance. Here, we only provide an idea for your reference.

The implementation mechanism is to add some attributes on each <tr> tag, as shown below:

<Tr meid = "true" id = 'tr _ <% # eval ("ID") %> 'style = "cursor: pointer; "Children = '<% # eval (" column1 ") %> 'onclick ="Getchild ('<% # eval ("ID") %> ')">

Add a class ID, and separate the IDs with commas (,). For example, id = '1' children = '2, 3,4, 5'

Onclick is triggered when you click. Set all the children node IDs to properties (display or hide ). Meid indicates whether to enable or contract

 

After this definition, you can write JSCodeNow, we need to implement it in recursive mode, as shown in the following JS Code:

 

VaR isexpend = true;
Function showhidden (idlist, isexpend ){
If (typeof idlist = "undefined "){
Return;
}
VaR array = idlist. Split (',');
For (VAR I = 0; I <array. length; I ++ ){
VaR id = array [I]. tostring ();
Getchild (ID );
If (isexpend = "false "){
$ ("# Tr _" + arraypolici2.16.tostring({}.css ({"display": "NONE"}); // shrink
}
If (isexpend = "true "){
$ ("# Tr _" + arraypolici2.16.tostring({}.css ({"display": "Block"}); // expand
}
}
}
Function getchild (ID ){
VaR list = $ ("# tr _" + id). ATTR ("children ");
If ($ ("# tr _" + id). ATTR ("meid") = "true "){
If ($ ("# tr _" + id ). find ("TD "). eq (1 ). find ("IMG "). size () = 1) {// if it is the primary root node, It is an image;
$ ("# Tr _" + id ). find ("TD "). eq (1 ). find ("IMG "). eq (0 ). ATTR ("src ",".. /images/folder.gif ");
}
$ ("# Tr _" + id ). find ("TD "). eq (1 ). find ("IMG "). eq (1 ). ATTR ("src ",".. /images/folder.gif ");
$ ("# Tr _" + id). ATTR ("meid", "false ");
Showhidden (list, "false ");
}
Else {
$ ("# Tr _" + id). ATTR ("meid", "true ");
If ($ ("# tr _" + id). Find ("TD"). eq (1). Find ("IMG"). Size () = 1 ){
$ ("# Tr _" + id ). find ("TD "). eq (1 ). find ("IMG "). eq (0 ). ATTR ("src ",".. /images/folder_open.gif ");
}
$ ("# Tr _" + id ). find ("TD "). eq (1 ). find ("IMG "). eq (1 ). ATTR ("src ",".. /images/folder_open.gif ");
Showhidden (list, "true ");
}
}

Write the SQL statement here:

Select a. ID, title, parentid, classlist, classlayer, sortid, pageurl, kindid, imgurl, descript, redzhaiyao, (Select convert (varchar (20), B. ID) + ','From dt_channel B where B. parentid = A. IDOrder by B. ID for XML Path (''))From dt_channel A where kindid = 4

Here we need to display all the nodes with multiple sub-nodes in a single field as new columns, for example:

Id title parentid

1 A 0

2 A1 1

3 A2 1

4 A3 1

So we can get

Id title parentid column1

1 A 0 2, 3, 4

The values 2, 3, and 4 are the children attribute values.

 

 

what are your opinions? Ha,

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.