LotusScript下的分页

表单页面放一个域,名字为curpage,域的defaultvalue写上@UrlQueryString 获取URL。再放一个display_list的计算域,用于显示列表和分页导航。
表单的webqueryopen写上@Command([ToolsRunMacro]; “gotopage”)调用代理。

后台代理gotopage代码如下:

Sub Initialize

On Error Goto label
Dim session As New NotesSession
Dim db As NotesDatabase
Dim curdoc As NotesDocument
Dim view As NotesView

Dim curpage As Integer ‘当前页码
Dim count As Integer ‘文档数量
Dim perpage As Integer ‘每页条目数量
Dim pages As Integer ‘页数
Dim ismod As Double ‘文档数量是否整除于每页数量
Dim i As Integer
Dim tempages As Integer
Dim dbname As Variant
Dim prepage As Integer
Dim pageurl As String
pageurl = “/f_levelandscorem?openform”
perpage = 2 ‘每页显示的条目数量,这个重点

Set db = session.CurrentDatabase
Set curdoc = session.DocumentContext
Set view = db.GetView(“v_levelandscorem”)
count = view.EntryCount

‘取视图文档
Dim doc As NotesDocument
Set doc = view.GetFirstDocument
Dim tmp As String,htmlstr As String
Dim v As Variant
v = Evaluate(“@WebDbName”,curdoc)
i = 1

‘是否有分页参数,有就不是第一页,必须获取页码
Forall temp In curdoc.curpage
If(Instr(temp,”page”)) Then
curpage = Cint(Strright(temp,”=”))
Else
curpage = 1
End If
End Forall

htmlstr = “<table border = 1><tr><td>重要性级别</td>”
htmlstr=htmlstr & “<td>点数</td><td>评分标准</td><td>操作</td></tr>”

‘============================================================
‘计算获得总共可以分多少页
‘============================================================
ismod = count Mod perpage
If ismod = 0 Then
pages = Cint( count \ perpage)
tempages = pages
Else
pages = Cint( count \ perpage + 1)
tempages = pages
End If

v = Evaluate(“@WebDbName”,curdoc)

‘=============================================================
‘分页
‘=============================================================

i = (curpage – 1 ) * perpage + 1
tempages = curpage * perpage

While(i <= tempages And i<=count)
Set doc = view.GetNthDocument(i)
‘取文档数据
tmp = doc.important(0)
htmlstr = htmlstr & “<td>” & tmp & “</td>”
tmp = doc.score(0)
htmlstr = htmlstr & “<td>” & tmp & “</td>”
tmp = doc.standard(0)

htmlstr = htmlstr & “<td>” & tmp & “</td>”

‘生成编辑
htmlstr = htmlstr & “<td><a href = ‘/” & v(0) & “/0/” & doc.UniversalID & _
“?editDocument’ >编辑</a>”

‘生成删除
htmlstr = htmlstr & {&nbsp;&nbsp;<a href=’javaScript:deldoc(“} & doc.UniversalID & {“)’>删除</a>}
htmlstr = htmlstr & “</td></tr>”

i = i + 1
Wend
tempages = pages
htmlstr = htmlstr & “<tr><td colspan = 4><a href=’/” &v(0) & “/f_levelandscore?openform’>增加分数和级别</a></td></tr>”
‘这里打印分页导航
prepage = curpage
htmlstr = htmlstr & “<tr><td colspan =4 >&nbsp;”

If ((prepage – 1) > 0) Then

htmlstr = htmlstr & {<a href =”/} & v(0) &  pageurl & {&pages=} & Cstr(prepage – 1) & {” >上一页</a>&nbsp;&nbsp;}
End If
i = 1
While(i <=tempages)

htmlstr = htmlstr & {<a href =”/} & v(0) & pageurl & {&pages=} & Cstr(i) & {” >第} & Cstr(i) & {页</a>&nbsp;}
i = i + 1
Wend
i = 1

If (curpage < pages) Then
htmlstr = htmlstr & {<a href =”/} & v(0) & pageurl & {&pages=} & Cstr(curpage + 1) & {” >下一页</a>&nbsp;}
End If

htmlstr = htmlstr & “</td></tr>”
htmlstr = htmlstr & “</table>”
curdoc.display_list = htmlstr

Exit Sub

label:
Msgbox “出错了,错在第 ” & Cstr(Erl) & ” 行,错误原因:” & Error
End Sub

打赏

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注