How paging works
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    > BEE Commands
    v Database Operation
       v Database Variables
          o Argument Variables
          o System Variables
          v Paging Variables
             o How paging works
             o Variables for paging
       > Database Actions
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> Database Operation >> Database Variables >> Paging Variables >> How paging works <=  =>      <  1  >  
How to use the display paging

As mentioned before, the "seek" parameter specify the position to start the next retrieval.  There are two more optional numbers in the "seek" parameter after the record to seek: the number of records per page (RPP, default is 10) and the number of pages per block (PPB, default is 10).  (A block is the collection of pages on the page navigation bar.)

With these three numbers, BEE will calculate the positioning of the pages on the page navigation bar and return an array.  The target page will contain the sought record.  For example, seek="71,10,5" means to seek record 71, with 10 records per page and 5 pages per block.  The page navigation bar should contain page 6 (record 51-60), page 7 (record 61-70), page 8 (record 71-80), page 9 (record 81-90) and page 10 (record 91-100).  The sought record (number 71) is in page 8.

If the sought record does not fall into the first record of the page, BEE will automatically change the "seek" position internally so that the next retrieval will always start from the first record of the page.  In the above example, if seek="73,10,5", the next retrieval will still start from 71 because it is the first record in the sought page (page 8).

This automatic repositioning does not apply unless the paging numbers (the second and/or the third number) are specified.  This will guarantee that you get what you want to seek if you are not interested in display paging.

Besides the positioning, we need to make sure the same record set is carried through to various pages of the same search.  This is done by keeping track of the last successful "select" query and resending it to the database platform in each page run.

The last successful query has been stored as a session variable.  All you need to do is to have query="{session%database:select}".  (Alternatively, if you want to use "action" mode, you can save the search criteria in dbobj%search and use it to generate a query in subsequent paging display.  This is a more complicated solution.  The "session" variable method is preferable unless you have a good reason not to use it.)

The format of the hyperlink to the pages can be specified in the dbobj%pagebar variable (input), and the system will generate the "cells" on the page bar and put them into the dbobj%page variable (output).

Example:

var href = "href=@self?record=@record";

 

var mydb%pagebar:first = "<a {href}>|&lt;&lt;</a>";

var mydb%pagebar:previous = "<a {href}>&lt;&lt;</a>";

var mydb%pagebar:back = "<a {href}>&lt;-</a>";

var mydb%pagebar:page = "<a {href}>@page</a>";

var mydb%pagebar:sought = "<b>@page</b>";

var mydb%pagebar:forward = "<a {href}>-&gt;</a>";

var mydb%pagebar:next = "<a {href}>&gt;&gt;</a>";

var mydb%pagebar:last = "<a {href}>&gt;&gt;|</a>";

 

var rec = "{form%record}";

if ({#rec:} == 0) var rec = 1;

 

var recordsperpage = 5;

var pagesperblock = 3;

 

database "mydb" query="{session%database:select}"

   seek="{rec},{recordsperpage},{pagesperblock}";

 

display "{pb%page|list:(@value)&nbsp;&nbsp;()}";

// If rec is 71 and there are 200 records in the record set,

// display          |<<  <<  <-  6  7  8  9  10  ->  >>  >>|

// hyperlink record=  1  41  61 51 61    81  91  81 101  191

 

Note: The "pagebar" definition in the above example is the default.  So the above initialisation is trivial unless you want to use different values (e.g. some button images.)

 

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd