| 实例详解利用xml创建可分页排序的数据显示页面 |
| 来源:
发布时间:2008-08-16 发布人:
浏览:
人次
字体:
[大
中
小]
|
|
'' 重新转换XML,并显示一个状态信息 Function redisplay(intPage) Dim strDisplay Dim intPageCount Dim intRecordCount '' 保存状态信息 intPageCount = PageCount.innerHTML intRecordCount = RecordCount.innerHTML transform() '' 显示状态信息 PageCount.innerHTML = intPageCount RecordCount.innerHTML = intRecordCount CurrentPage.innerHTML = intPage End Function '' 重新排序和显示 Function Sort(strField) Dim sortField Dim sortOrderAttribute '' 得到排序属性值 Set sortField = Style.XMLDocument.selectSingleNode("//xsl:sort/@select") Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//xsl:sort/@order") '' 改变排序的方式 If sortField.Value = strField Or sortField.Value = "./*[0]" Then If sortOrderAttribute.Value = "descending" Then sortOrderAttribute.Value = "ascending" Else sortOrderAttribute.Value = "descending" End If Else sortField.Value = strField sortOrderAttribute.Value = "ascending" End If Set sortField = Nothing Set sortOrderAttribute = Nothing redisplay (CurrentPage.innerHTML) End Function '' 重新设置每页的记录数 Function setRecordsPerPage() If IsNumeric(RecordsPerPage.Value) Then intRecordsPerPage = CInt(RecordsPerPage.Value) window_onload End If End Function '' 显示页数信息 Function setPageCount() Dim intTotalRecords PageCount.innerHTML = getNumberOfPages(intTotalRecords) RecordCount.innerHTML = intTotalRecords CurrentPage.innerHTML = 1 End Function '' 计算总页数和总记录数 Function getNumberOfPages(intTotalRecords) Dim intPages intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length intPages = intTotalRecords / intRecordsPerPage If InStr(intPages, ".") > 0 Then intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1 End If getNumberOfPages = intPages End Function '' “下一页”的处理 Function nextPage(intPage) Dim strDisplay Dim strDateRange If CInt(CStr(intPage) * intRecordsPerPage) < Data.selectNodes("/*/*").length Then intPage = CInt(intPage) + 1 Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")" Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")" Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]" redisplay (intPage) End If End Function '' 处理“上一页” Function previousPage(intPage) Dim strDisplay Dim strDateRange If intPage > 1 Then intPage = CInt(intPage) - 1 Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")" Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")" Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]" redisplay (intPage) End If End Function
共5页: 上一页 [1] [2] [3] 4 [5] 下一页
| |
| |
|
|
|
|
| §最新评论:(评论内容只代表网友观点,与本站立场无关!) | |
|
|
|
|
| 注意:请勿在本站发布政治话题、色情及违反法律的内容。 |
IT知道网 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。 |