Previous Thread
Next Thread
Print Thread
XTREE Application-controlled paging #37426 01 Jul 24 11:05 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline OP
Member
OP Offline
Member
J
Joined: Jun 2001
Posts: 11,794
Quote

Let's suppose you're displaying data ten rows at a time, assuming is all it fits on the screen, but you want to go back and forth the same ten records each time, like if you were paginating.

If you have 40 records:

First time: display 1-10 records.

Go forward

Display 11-20 records.

Go forward

Display 21-31 records

Go backwards

Display 11-20 records

And so on.

I've tried with XTR.TARGETROW and with XTR.TOPINDEX.

Topindex was hopeful and going forward it seemed to work but probably I don't know how it exactly works because suddenly I started to get weird numbers. I used a temporary floating point variable to keep track of the record position, because according to the documentation, topindex is a B,4 and negatives are not allowed, but anyway no matter I add or subtract a fixed amount of records, at some point the variable value became unexplainable to me. I believe it's related to how XTREE assigns the topindex value on entering and exiting, but I'm not sure.

Probably is just that topindex is not intended for this purpose.

A possible approach is to use a temporary matrix of 10 records (continuing with the example) and clear, load and display the records each time but I think this would be overkill and very likely there are simpler solutions using only the original matrix.

I hope I just don't see some very clear parameter!!!


Offhand I don't see why XTR.TOPINDEX doesn't work, although XTR.TARGETROW would probably have to be compatible (on the same 'page') or equal to XTR.TOPINDEX.
I'll try to create a test case and report back...

Re: XTREE Application-controlled paging [Re: Jack McGregor] #37427 01 Jul 24 11:37 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline OP
Member
OP Offline
Member
J
Joined: Jun 2001
Posts: 11,794
Ok, I created a sample program based on the existing XTR2 sample. You can download it from the EXLIB repository (xtra2pg.bp)

Other than the buttons to page forward and back, the code is all right here (edit [200]) ...
Code
    XTR.TOPINDEX = 1        ! [200] activate feature and start on row 1

    do        
        xcall XTREE,SROW,SCOL,ANSWERX,XTREE'DATA(1 ),MAXCHOICE,COLDEF$, &
            EXITCODE,EROW,ECOL,XTFLAGS,"",XTREE'MMOCLR,XTR  

        XTR.OPCODE = XTROP_RESELECT     ! after initial create, default will be just to reselect
        
        if EXITCODE = -301 then             ! [200] Page forward +10 rows
            XTR.TOPINDEX = (XTR.TOPINDEX + 10) min MAXCHOICE
            XTR.TARGETROW = XTR.TOPINDEX
            repeat
        endif
        if EXITCODE = -302 then             ! [200] Page back -10 rows
            XTR.TOPINDEX = (XTR.TOPINDEX - 10) max 1
            XTR.TARGETROW = XTR.TOPINDEX
            repeat
        endif
        ...

Possible issues you may have been running into:
  • You have to enable the XTR.TOPINDEX feature by setting it to a non-zero value.
  • The XTR.TOPINDEX variable is B,4, so if you have to be careful about letting it go negative. I used the min and max operators to confine it to the range from 1 to the number of rows.
  • XTR.TARGETROW probably needs to be set to the same value, else the focus row may override the top index row.


The paging may get weird if you activate the multi-level feature; I suggest just hitting ENTER to each of the setup prompts to get the simple version.


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3