|
功能列表:
搜索功能
首页按钮
最后一页
上一页
下一页- import win.ui;
- /*DSG{{*/
- var winform = ..win.form( bottom=399;parent=...;text="aardio Form";right=599 )
- winform.add( )
- /*}}*/
- import sqlite.aes128;
- var sqlConn = sqlite.aes128("/database.db",key)
- if( not sqlConn.existsTable("black") ){
- sqlConn.exec("create table black(name, address integer default 0);")
- sqlConn.beginTrans();
- for(i=101;200;1){
- sqlConn.exec("insert into black(address) values('"+ i + "');")
- }
- sqlConn.commitTrans();
- }
-
-
- import web.layout;
- import web.layout.behavior.tabs;
- var wbLayout = web.layout(winform);
- import web.layout.debug; //导入该库以显示HTMLayout错误
- wbLayout.attachEventHandler( web.layout.debug ); //为CSSS!添加全局函数 debug;
- wbLayout.html = /*********
- <html>
- <head>
- <style>
- html { background-color: #fff #e9e8f3 #e9e8f3 #fff; }
- table
- {
- background:white;
- border:1px solid #bdbccc;
- width:100%%;
- height:100%%;
- behavior:grid column-resizer;
- overflow:auto;
- flow: table-fixed;
- font-family:"Verdana";
- font-size:9pt;
- border-spacing:0;
- }
- table th
- {
- color: white;
- font-family:"Century Gothic","Verdana";
- font-size:14pt;
- border-right:1px solid silver;
- border-bottom:1px solid silver;
- padding:4px;
- background-color:#AAA;
- }
- table th:hover
- {
- color: #ffe598;
- }
- table tr { height:1.6em; }
-
- table tr:current /* current row */
- {
- background-color:#bdbccc;
- color:white;
- }
- table tr:nth-child(odd)
- {
- background-color: azure;
- }
- table td
- {
- padding:2px;
- border-right:1px solid silver;
- border-bottom:1px solid silver;
- }
- table td:nth-child(1) { font-weight:bold; text-align:center; } /* first column */
- table td:nth-child(3) /* last column */
- {
- text-align:left;
- overflow:hidden; /* three line below - ellipsis */
- text-overflow:ellipsis;
- white-space:nowrap;
- }
-
- table td:hover
- {
- color:red;
- }
-
- #statusbar{
- padding-top:10px;
- }
-
- </style>
-
- </head>
- <body>
- <p>数据列表</p>
-
- <p><input type="text" id="filter" value=""><input type="button" id="Search" value="搜索"></p>
-
-
- <table width=100% fixedrows=1 id="test">
- <tr><th width=40%>地址</th><th width=20%>AA</th><th width=20%>BB</th><th width=20%>CC</th></tr>
- </table>
-
-
-
- <input type="button" id="FirstPage" value="首页">
- <input type="button" id="PreviousPage" value="上一页">
- <input type="button" id="NextPage" value="下一页">
- <input type="button" id="LastPage" value="最后一页">
- <div id="statusbar">总数量:<span id="count">0</span><span style="padding-left:20px;">当前页:</span><span id="CurrentPage">1</span><span style="padding-left:20px;">共:</span><span id="NumTotalPage">0</span>页</div>
- </body>
- </html>
- *********/
-
- replaceNull = function(str){
- if(!str){
- return "";
- }else {
- return str;
- }
- }
- replaceSending = function(sending){
- if(sending='N'){
- return "NoSending";
- }else {
- return "";
- }
- }
- var filter=""
- var numTotal = 0;
- var CurrentPage = 1;
- var NumTotalPage =0;
- Address = sqlConn.getTable("SELECT COUNT(*) FROM black" )
- numTotal = Address[1]["COUNT(*)"];
- wbLayout.getEle("count").innerText = numTotal;
- //
- Listing = function(Filter,Page){
- ItemPerNum = 10;
- wbLayout.getEle("CurrentPage").innerText = CurrentPage;
-
- strCondition ="";
- strSQL = "select address, name from black ";
- if(string.len(filter)>0){
- strCondition = "WHERE address LIKE'%" + Filter + "%' ";
- }
- Offset = (CurrentPage-1) * ItemPerNum;
- strSQL = strSQL + strCondition + "ORDER BY address LIMIT " + ItemPerNum +" OFFSET "+Offset;
-
-
- var eles = wbLayout.queryEles("tr[data='row']");
- for(i,ele in eles){
- ele.delete();
- };
-
- var sqlConn = sqlite.aes128("/database.db",key)
-
- Address = sqlConn.getTable("SELECT COUNT(*) FROM black " + strCondition)
- numTotal = Address[1]["COUNT(*)"]
- wbLayout.getEle("count").innerText = numTotal;
-
- NumTotalPage = math.ceil(numTotal/ItemPerNum); //获得总页数
- wbLayout.getEle("NumTotalPage").innerText = NumTotalPage;
-
- for address,time_created,time_sent,sending in sqlConn.each(strSQL ) {
- wbLayout.getEle("test").insertAdjacentHTML("beforeEnd","<tr data='row' class='" + replaceSending(sending)+"'>"+
- "<td>"+replaceNull(address)+"</td>"+
- "<td>"+replaceNull(time_created)+"</td>"+
- "<td>"+replaceNull(time_sent)+"</td>"+
- "<td>"+replaceNull(sending)+"</td>"+
- "</tr>");
- }
- sqlConn.close();
- }
- Listing("");
-
- wbLayout.onButtonClick = {
- FirstPage = function (layoutEle,reason,behaviorParams) {
- filter = string.trim(wbLayout.getEle("filter").value);
- CurrentPage = 1;
- Listing(filter);
- }
- LastPage = function (layoutEle,reason,behaviorParams) {
- filter = string.trim(wbLayout.getEle("filter").value);
- CurrentPage = NumTotalPage;
- Listing(filter);
- }
-
- PreviousPage = function (layoutEle,reason,behaviorParams) {
- filter = string.trim(wbLayout.getEle("filter").value);
- CurrentPage =CurrentPage-1;
- if(CurrentPage<1){
- CurrentPage = 1; // 如果当前页<1
- }
- Listing(filter);
- }
- NextPage = function (layoutEle,reason,behaviorParams) {
- filter = string.trim(wbLayout.getEle("filter").value);
- CurrentPage = CurrentPage+1;
- if(CurrentPage>NumTotalPage){
- CurrentPage = NumTotalPage;
- }
- Listing(filter);
- }
- Search = function (layoutEle,reason,behaviorParams) {
- filter = string.trim(wbLayout.getEle("filter").value);
- CurrentPage = 1;
- Listing(filter);
- }
- }
- sqlConn.close();
- winform.show();
- win.loopMessage();
- return winform,wbLayout;
-
复制代码 |
评分
-
查看全部评分
|