Lotus Domino:在Web上查看分页 [英] Lotus Domino: View pagination on web

查看:100
本文介绍了Lotus Domino:在Web上查看分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在许多论坛上阅读了有关如何实现视图页面对齐的解决方案的信息,但是我没有解决它.

I read on many forums about how to implement a solution for view pagionation, but I didn't solve it.

我创建了$$ViewTemplateDefault,其中包含一些用于NextPrevious的个性化热点按钮和一个文本字段$$ViewBody. (或替代地,嵌入视图).

I created $$ViewTemplateDefault containing some personalized hotspotbuttons for Next, Previous and a text field $$ViewBody. ( or, alternatively, an embedded view ).

任何提示和帮助将不胜感激.

Any tips and help will be really appreciated.

为了清楚起见,我将用几句话进行解释:

I will explain in a couple words, just to be clear:

因此,最初:前30行将出现在右上角=>:第1页.

So, initially: the first 30 lines will appear => in a right corner: Page 1.

如果单击下一步" =>接下来的30行=>第2页,依此类推.

If Next is clicked => the next 30 lines => Page 2. and so on.

推荐答案

这里也是分类视图的有效解决方案.它根据上一个页码计算当前页码,并使用cookie.

Here is a working solution for categorized views too. It calculates the current page number based on the previous page number and uses cookies.

在页眉中添加一个Path-Thru HTML文本<span id="pageNumber"></span >作为页码:

Add to your form a Path-Thru HTML text <span id="pageNumber"></span > for the page number:

并将以下代码作为Web/JavaScript添加到表单的onLoad事件中:

and add following code to form's onLoad event as Web/JavaScript:

function getURLParameter(parameter) {
  return decodeURIComponent((new RegExp('[?|&]' + parameter + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
}
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name)==0) return c.substring(name.length,c.length);
    }
    return "";
}
function compareStart(start1, start2) {
    var list1 = start1.split(".");
    var list2 = start2.split(".");
    for (i=0; i <100; i++) {
        var value1 = list1[i];
        var value2 = list2[i];
        if (value1 == null) {
            return value2 == null ? 0 : -1;
        } else if (value2 == null) {
                return 1;
        }
        value1 = Math.round(value1);
        value2 = Math.round(value2);
        if (value1 !== value2) {
            return value1 < value2 ? -1 : 1;
        }
    }
}
var start = getURLParameter("Start");
var page = "1";
if  (start == null || start === "1") {
    window.name = Math.floor((Math.random()*10000)+1);
    start = "1";
} else {
    page =  getCookie("page" + window.name);
    var oldStart = getCookie("start" + window.name);
    page = Math.round(page) + compareStart(start, oldStart);
}
document.getElementById('pageNumber').innerHTML = page;
document.cookie = "page" + window.name + "=" + page;
document.cookie = "start" + window.name + "=" + start;

它如何工作?

命令@DbCommand("Domino"; "ViewNextPage")@DbCommand("Domino"; "ViewPreviousPage")返回带有参数& Start ="的URL.这是当前页面开始的视图中的行号.对于分类视图,它们返回诸如& Start = 1.2.4.2"之类的分层编号.这意味着该视图从第一个主要主题,子主题2,子主题4,文档2开始.

The commands @DbCommand("Domino"; "ViewNextPage") and @DbCommand("Domino"; "ViewPreviousPage") return an URL with parameter "&Start=". This is the row number in view where the current page starts. For categorized views they return a hierarchical number like "&Start=1.2.4.2". That means that the view starts at the first main topic, subtopic 2, subsubtopic 4, document 2.

此参数& Start ="使我们可以识别用户是否按了"prev"或"next":我们只比较当前页面和前一页的URL& Start ="参数.

This parameter "&Start=" gives us the possibility to recognize if user pressed "prev" or "next": we just compare the URL "&Start=" parameter of current and former page.

为此,我们必须记住URL& Start ="参数,并将其放入cookie"start".

For that, we have to remember the URL "&Start=" parameter and put it into a cookie "start".

我们还需要保存当前页码.我们将其放入Cookie的页面"中.

We also need to save the current page number. We put it into a cookie "page".

onload事件中,我们根据上一个页码计算当前页码:

At onload event we calculate the current page number based on previous page number:

  • 如果& Start =参数现在更大,那么我们加1
  • 如果& Start =参数现在变小,则我们减去1
  • 如果& Start =参数未更改,则我们保留以前的值

如果& Start =参数为空,则说明我们在第1页上.

If "&Start=" parameter is empty we know we are on page 1.

这是我们必须处理的另一件事:cookie是按用户会话而不是按浏览器选项卡保存的.这意味着,如果我们在浏览器中打开了两个视图,则将使用相同的Cookie开始"和页面".为了避免这种情况,我们必须在Cookie名称中添加一些特定于选项卡的标签.我为此使用了一个随机的四位数,并将其保存在特定于制表符的window.name中.

Here is one other thing we have to deal with: cookies are saved per user session not per browser tab. That means, if we have two views open in browser same cookies "start" and "page" would be used. To avoid that, we have to add to cookie name something tab specific. I use for that a random four digit number and save it in window.name which is tab specific.

这篇关于Lotus Domino:在Web上查看分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆