Nov 17, 2015, 4:08 AM
177 Posts

Custom pager function for repeat / view control

  • Category: Extension Library
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: view,repeate control
  • Replies: 2

is it possible to write a custom function to load a new set of documents for a repeat control (or view) ?

I use the xe:pagerAddRows control but in conjuction with an infinite scroll function this triggers often multiple ajax requests and I have no control on them because the simple:

 $(".infiniteScroll ul li a").click();

event is triggered.

I rather make the ajax call myself so I set a state for the window in order to prevent multiple ajax requests e.g. something as in:

 

$(window).scroll(function(e) {
    e.preventDefault();
    if ($(window).scrollTop() >= ($(document).height() - $(window).height())) {
        $('div#loadmoreajaxloader').show();
        $.ajax({
            cache: false,
            url: 'loadmore.php?lastid=' + $('.postitem:last').attr('id'),
            success: function(html) {
                if (html) {
                    $('#postswrapper').append(html);
                    $('div#loadmoreajaxloader').hide();
                } else {
                    $('div#loadmoreajaxloader').html();
                }
            }
        });
    }
});
Nov 17, 2015, 11:30 AM
453 Posts
Some thoughts

I add a pager to repeat controls all the time but I just use a standard xp:pager control. The issue with this is that when I open a document for CRUD I loose the position in the repeat. So you need to get the repeat controls "first" value and store it so that on return you can set the repeat control first value back. I store the value of first in a sessionScope variable. 

So my pager looks something like this:

<xp:pager layout="Previous Group Next" partialRefresh="true"
                    id="pager1" for="repeat1">
                    
 </xp:pager>

then my repeat sets the value of the first property like this:

<xp:this.first><![CDATA[#{javascript:if (sessionScope.ssCat1First == "" || sessionScope.ssCat1First == null){
    sessionScope.ssCat1First = 0;
    return 0
}else{
    return sessionScope.ssCat1First
}}]]>
</xp:this.first>

Then in the link to open a document I add:

sessionScope.ssFirst = getComponent("repeat1").first;

This works well for me, and I almost never use anything but a repeat control for displaying documents. I did a session for Dave on NotesIn9 demonstrating categorized repeat controls. http://www.notesin9.com/tag/repeat-control/

I don't think I had the pager in that demo but it would not take much to add it.

Nov 18, 2015, 4:41 PM
453 Posts
Updated the NotesIn9 database to handle pagers

in the original NotesIn9 database (download at http://wfsystems.ca ) pagers of the different levels of the categorized repeats were not handled well. However, that was not really the purpose of the demo, but they did not handle them well. I have modified the database and now there is a pager for every level of a categorized repeat and the pager is hidden if it is not needed.