I read some of this post and learned a lot. Now I want to share it with you.
Flash is only a display function. When I read some other things, I think there seems to be a very simple implementation method for paging.
Basically, they are transmitted in XML format.
The list component and the DataGrid can be used for display. Here I use dynamic text, because I think the component is too troublesome.
So I used a stupid way. I couldn't find a better solution ~~~
In the following code, list [...] is the name of dynamic text. 15 entries are displayed at a time.
// The display program is as follows:
// Region name "list"
Stop ();
VaR loglist = New XML ();
VaR logroot;
VaR page: Number; // current page
VaR tpage: Number; // Save the total page
VaR tnum: Number; // The total number of logs.
VaR LOGNAME: string; // log category name
VaR temp;
VaR I: number;
// Here I use an array to store the corresponding ID number. If I use a component, I don't have to worry about it.
VaR IDs = new array (15 );
// Two buttons for paging
Bn_u.enabled = false;
Bn_d.enabled = false;
If (page = NULL or page <1 ){
Page = 1;
}
//------------------------------
// Clear the function;
Function myclear (){
For (I = 1; I <16; I ++ ){
IDS [I-1] = 0;
List ["LBN" + I]. _ visible = false;
List ["ltitle" + I]. Text = "";
List ["lauthor" + I] = "";
List ["ltime" + I] = "";
}
}
//--------------------------------------
//--------------------------------------
Myclear ();
Pageinfo. Text = "reading data ...";
Loglist. ignorewhite = true;
Loglist. Load ("tree_list.asp? Log_cat = "+ cat_id +" & page = "+ page );
//------------------------------------------------
// Get data Function
Function logfunc (e ){
If (e ){
Logroot = loglist. firstchild;
LOGNAME = logroot. Attributes. LOGNAME;
Tpage = logroot. Attributes. tpage;
Tnum = logroot. Attributes. tnum;
Temp = logroot. firstchild;
List. ltitle1.text = ftitle (temp. firstchild. nodevalue, 22 );
List. lauthor1 = temp. Attributes. Author;
List. ltime1 = temp. Attributes. addtime;
IDS [0] = temp. Attributes. ID;
I = 1;
List. lbn1. _ visible = true;
// Read nodes cyclically
While (temp. nextsibling! = NULL ){
Temp = temp. nextsibling;
I ++;
// If it is displayed in another way, you only need to change it.
IDS [I-1] = temp. Attributes. ID;
List ["LBN" + I]. _ visible = true;
List ["ltitle" + I]. Text = ftitle (temp. firstchild. nodevalue, 22 );
List ["lauthor" + I] = temp. Attributes. Author;
List ["ltime" + I] = temp. Attributes. addtime;
}
Pageinfo. Text = LOGNAME + "Total logs" + tnum + "Total" + tpage + "page" + Page + "page" + "15/page ";
Bn_u.enabled = true;
Bn_d.enabled = true;
} Else {
Pageinfo. Text = "No logs currently. ";
List. ltitle1.text = "An error occurred while reading data. Please contact the administrator! ";
}
}
// A custom format title function, for fear that the title is too long
Function ftitle (S, N ){
If (length (s)> N ){
S = S. substring (0, n-1) + "...";
}
Return S;
}
Loglist. onload = logfunc;
//-------------------------------------
// Button action
Bn_up = new object ();
// Button event to determine whether the page size exceeds the value
Bn_up.click = function (EVT ){
If (page> 1 ){
_ Root. Page --;
Gotoandplay ("Cycle ");
} Else {
Stop ();
}
};
Bn_d = new object ();
Bn_d.click = function (EVT ){
If (page <tpage ){
_ Root. Page ++;
Gotoandplay ("Cycle ");
} Else {
Stop ();
}
};
Bn_u.addeventlistener ("click", bn_up );
Bn_d.addeventlistener ("click", bn_d );
Cycle "Cycle" has only one statement:
Gotoandplay ("list ");
// Form a simple Loop
Tree_list.asp:
// Log is my log table and log_cat is a classification table.
The following ASP is clear:
<? XML version = "1.0" encoding = "gb2312"?>
<%
Response. contenttype = "text/XML"
Response. cachecontrol = "no-Cache"
Response. addheader "Pragma", "No-Cache"
Response. expires = 0
Dim log_cat, page, pagesize, tnum, tpage, log_name
Page = treerequest ("page", 1)
Log_cat = treerequest ("log_cat", 1)
Pagesize = 15
Call tree_rs
If log_cat = 0 or log_cat = "" then
SQL = "select * From log order by written_time DESC, log_id DESC"
Else
SQL = "select * From log, log_cat where log. cat_id = log_cat.id and cat_id =" & log_cat & "order by written_time DESC, log_id DESC"
End if
Rs. Open SQL, Conn, 1, 1
Rs. pagesize = pagesize
Tnum = Rs. recordcount
Tpage = int (tnum/pagesize *-1) *-1
If page = "" Then page = 1
If tnum <> 0 then Rs. absolutepage = page
If log_cat = 0 or log_cat = "" then
Log_name = "[All categories]"
Else
Log_name = "[" & RS ("cat_name") & "]"
End if
'Output below XML
'------------------------------------------------
Response. Write ("<tree LOGNAME = '" & log_name & "'tnum ='" & tnum & "'tpage = '" & tpage & "'> ")
If Rs. EOF then
Rs. Close
Else
Do while not Rs. EOF and pagesize> 0
Response. write ("<trees author = '" & RS ("log_author") & "'addtime ='" & RS ("written_time ") & "'id = '" & RS ("log_id") & "'> ")
Response. Write ("<! [CDATA ["& RS (" log_tittle ") &"]> </trees> ")
Pagesize = pageSize-1
Rs. movenext
Loop
Rs. Close
End if
// Disable rs
Call tree_rsclose
Call tree_conclose
Response. Write ("</tree> ")
%>
The Code seems messy. I hope it will be helpful to my friends who are doing this. If the above bug exists, please advise.
This post is transferred from: http://hi.baidu.com/guodong828/blog/item/0ad2bb6ee76ad1da81cb4ad1.html