Reposition scrollbar to position before pui click refresh

Use this board for starting discussions, asking questions, and giving advice on Web programming for the IBM i platform (and predecessors.)
JacobPreston
New User
Posts: 10
Joined: Fri Apr 05, 2019 4:09 pm
First Name: Jacob
Last Name: Preston
Company Name: Preston Software
Contact:

Reposition scrollbar to position before pui click refresh

Post by JacobPreston »

I have a subfile with checkboxes containing an onchange event to trigger pui.click();. When a checkbox is checked or unchecked, certain changes will be applied to the subfile record with that checkbox. In the example, i'm just changing the color for one of the fields.

Here is a video demonstrating the issue I'm having
https://www.youtube.com/watch?v=UfNjkCkYUl0

Is there any way I can reposition the subfile to be at the exact spot it was before the pui.click(); occurs?

RPGLE Program:

Code: Select all

     HDATFMT(*iso)
     HTIMFMT(*HMS)
     H DFTACTGRP(*NO)
      /DEFINE PROFOUNDUI
     h option(*nodebugio:*srcstmt:*noexpdds)
     H**********************************************************
     H* Author...: Jacob Preston
     H* Date.....: 12/02/2019
     H*
     f**********************************************************
     fZDEMO100S cf   e             workstn handler('PROFOUNDUI(HANDLER)')
     f                                     extfile('ZDEMO100S')
     f                                     sfile(ZDEMO1002:@rrn)
     f                                     infds(info)
     f
     d**********************************************************
     d*Variable Declarations
     d reccount        s              5  0
     d i               s              5  0
     d*Constants
     d crlf            C                   CONST(X'0d25')
     d*Exit Hotkey                         F3
     dexit             c                   const(X'33')
     d*Cancel Hotkey                       F12
     dcancel           c                   const(X'3C')
     d*Enter Hotkey                        Enter
     denter            c                   const(X'F1')
     d
     dinfo             ds
     d  screenrec        *record
     d  cfkey                369    369
     d
     c**********************************************************
      /FREE
        exsr Main;
        *inlr = *on;

       //*********************************************************************
       //  LoadSfl --  Load test data into subfile
       //*********************************************************************
       begsr LoadSfl;
         @rrn=0;
         *in31 = *on; //Clear Subfile
         write ZDEMO1001;
         *in30 = *off; //Display Subfile
         *in31 = *off; //Display Control Record

         for i = 1 to 30;
           sflselect = 'F'; //Unchecked
           hdselect = sflselect; //Previous value for sflselect checkbox
           sfvalue = i;
           sfcolor = '#000000';
           @rrn += 1;
           write ZDEMO1002; //Write subfile rec
         endfor;
         *in99 = *on; //EOF

         reccount = @rrn;
         @rrn = 1; //Position to top of subfile

       endsr;

       //*********************************************************************
       // Main - Show the Category List
       //*********************************************************************
       begsr Main;
         exsr LoadSfl;
         DOW *inlr=*off;
           exfmt ZDEMO1001;

           select;
             when cfkey=exit or cfkey=cancel;
               leave;

             when cfkey=enter;
               for i = 1 to reccount;
                 chain(e) i ZDEMO1002;
                 if not %error;
                   if hdselect <> sflselect;
                     hdselect = sflselect;
                     if sflselect = 'T';
                       sfcolor = '#DD0000'; //If selected, red text
                     else;
                       sfcolor = '#000000'; //If not selected, black text
                     endif;
                     update ZDEMO1002;
                     leave; //Only one can be updated per pui refresh so leave
                   endif;
                 endif;
               endfor;
               @log = %trim(@log) + crlf + 'rrn = ' + %char(@rrn);
               iter;
           endsl;
         enddo;
       endsr;

      /END-FREE
Display File:

Code: Select all

     A          R ZDEMO1002                 SFL
     A            QPUI000001     1A  O  2  2
     A            HDSELECT       1A  H
     A            SFCOLOR       10A  H
     A            SFLSELECT      1A  H
     A            SFVALUE        5S 0H
     A          R QSFLCTL001                SFLCTL(ZDEMO1002)
     A                                      SFLSIZ(0001)
     A                                      SFLPAG(0001)
     A                                      SFLDSP
     A                                  1  2HTML('QPUISFLZDEMO1001')
     A          R ZDEMO1001
     A  31 99 30                            CA01
     A                                  1  2HTML('QPUICTL1    ZDEMO1002 5    RS-
     A                                      FLDSP    0    E1    3    N30RSFLDSP-
     A                                      CTL 0    E1    3    N31RSFLCLR    0-
     A                                          E1    3     31RSFLPAG    1    C-
     A                                      1    5 RSFLSIZ    1    C1    6 0   -
     A                                       0    ')
     A                                  1  2HTML('{"screen":{"record format nam-
     A                                      e":"ZDEMO1001","description":"Contr-
     A                                      ol Model Attribute List","document -
     A                                      title":"Attribute Model Attribute A-
     A                                      ssignment"},"items":[{"id":"Exit","-
     A                                      field type":"button","css class":"b-
     A                                      utton","value":"Exit","left":"905px-
     A                                      ","top":"415px","width":"120px","sh-
     A                                      ortcut key":"F3"},{"id":"Grid1","fi-
     A                                      eld type":"grid","css class":"bluep-
     A                                      rint-grid","left":"355px","top":"12-
     A                                      5px","border color":"transparent","-
     A                                      column headings":"Select,Value,","c-
     A                                      olumn widths":"100,120","css class -
     A                                      2":"blueprint-defaults","header hei-
     A                                      ght":"35","height":"210px","number -
     A                                      of columns":"2","number of rows":"6-
     A                                      ","row height":"35","visibility":"v-
     A                                      isible","width":"221px","record for-
     A                                      mat name":"ZDEMO1002","subfile reco-
     A                                      rd number":{"fieldName":"@RRN","dat-
     A                                      aLength":"5","decPos":"0","numSep":-
     A                                      "false","zeroBalance":"false","numB-
     A                                      lankFill":"false","zeroFill":"false-
     A                                      ","noExtraSpaces":"false","curSym":-
     A                                      "","dataType":"zoned","formatting":-
     A                                      "Number","negNum":"-999.00","units"-
     A                                      :""},"display subfile":{"fieldName"-
     A                                      :"N30","customTrue":"","customFalse-
     A                                      ":"","dataType":"expression","forma-
     A                                      tting":"Indicator","indFormat":"tru-
     A                                      e / false"},"display control record-
     A                                      ":{"fieldName":"N31","customTrue":"-
     A                                      ","customFalse":"","dataType":"expr-
     A                                      ession","formatting":"Indicator","i-
     A                                      ndFormat":"true / false"},"clear su-
     A                                      bfile":{"fieldName":"31","customTru-
     A                                      e":"","customFalse":"","dataType":"-
     A                                      expression","formatting":"Indicator-
     A                                      ","indFormat":"true / false"},"subf-
     A                                      ile end":{"fieldName":"99","customT-
     A                                      rue":"","customFalse":"","dataType"-
     A                                      :"expression","formatting":"Indicat-
     A                                      or","indFormat":"true / false"}},{"-
     A                                      id":"TextArea1","field type":"text -
     A                                      area","value":{"fieldName":"@log","-
     A                                      dataLength":"9999","trimLeading":"f-
     A                                      alse","trimTrailing":"true","blankF-
     A                                      ill":"false","rjZeroFill":"false","-
     A                                      dataType":"char","formatting":"Text-
     A                                      ","textTransform":"none","designVal-
     A                                      ue":"[@log]"},"left":"615px","top":-
     A                                      "130px","height":"205px","width":"3-
     A                                      55px","color":"#000000"},{"id":"Out-
     A                                      putField1","field type":"output fie-
     A                                      ld","css class":"outputField","valu-
     A                                      e":{"fieldName":"sfvalue","dataLeng-
     A                                      th":"5","decPos":"0","numSep":"fals-
     A                                      e","zeroBalance":"false","numBlankF-
     A                                      ill":"false","zeroFill":"false","no-
     A                                      ExtraSpaces":"false","curSym":"","d-
     A                                      ataType":"zoned","formatting":"Numb-
     A                                      er","negNum":"-999.00","units":"","-
     A                                      designValue":"[sfvalue]"},"left":"1-
     A                                      0px","top":"10px","css class 2":"bl-
     A                                      ueprint-defaults","css class 3":"bl-
     A                                      ueprint-output-field","color":{"fie-
     A                                      ldName":"sfcolor","dataLength":"10"-
     A                                      ,"trimLeading":"false","trimTrailin-
     A                                      g":"true","blankFill":"false","rjZe-
     A                                      roFill":"false","dataType":"char","-
     A                                      formatting":"Text","t')
     A                                  1  2HTML('extTransform":"none"},"grid":-
     A                                      "Grid1","column":"1"},{"id":"Output-
     A                                      Field2","field type":"output field"-
     A                                      ,"css class":"outputField","value":-
     A                                      {"fieldName":"hdselect","dataLength-
     A                                      ":"1","trimLeading":"false","trimTr-
     A                                      ailing":"true","blankFill":"false",-
     A                                      "rjZeroFill":"false","dataType":"ch-
     A                                      ar","formatting":"Text","textTransf-
     A                                      orm":"none","designValue":"[hdselec-
     A                                      t]"},"left":"20px","top":"10px","cs-
     A                                      s class 2":"blueprint-defaults","cs-
     A                                      s class 3":"blueprint-output-field"-
     A                                      ,"visibility":"hidden","color":"#00-
     A                                      0000","grid":"Grid1","column":"0"},-
     A                                      {"id":"Checkbox1","field type":"che-
     A                                      ckbox","value":{"fieldName":"SFLSEL-
     A                                      ECT","dataLength":"1","trimLeading"-
     A                                      :"false","trimTrailing":"true","bla-
     A                                      nkFill":"false","rjZeroFill":"false-
     A                                      ","dataType":"char","formatting":"T-
     A                                      ext","textTransform":"none","design-
     A                                      Value":"[SFLSELECT]"},"left":"5px",-
     A                                      "top":"10px","checked value":"T","u-
     A                                      nchecked value":"F","onchange":"pui-
     A                                      .click();","grid":"Grid1","column":-
     A                                      "0"}]}')
     A            @LOG        9999A  H
     A            @RRN           5S 0H
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Reposition scrollbar to position before pui click refresh

Post by Scott Klement »

It's not clear why you're using the RPG program to change the color rather than changing it in JavaScript? Maybe you need this info in your program? Or maybe you need it to be re-drawn with the same values later?

Please remember that if you do EXFMT (or write/read) to display a screen, it has to redraw that screen. You say its "repositioning" the subfile, that's not quite accurate. It's deleting the entire screen and redrawing everything from the ground up -- including drawing a new subfile. It positions the subfile according to the same rules it would in a green-screen (5250) environment... it starts at row 1 unless you use the "subfile record number" to tell it to display starting with a different row.

So that's one way to solve the problem: Code the "subfile record number" property (the Rich DIsplay equivalent to the SFLRCDNBR DDS keyword)

On the other hand, if you changed it from JavaScript code, you could change it without submitting the screen back to the RPG, and therefore there'd be no need to redraw the subfile or anything like that. The color would just change, that's it.
JacobPreston
New User
Posts: 10
Joined: Fri Apr 05, 2019 4:09 pm
First Name: Jacob
Last Name: Preston
Company Name: Preston Software
Contact:

Re: Reposition scrollbar to position before pui click refresh

Post by JacobPreston »

Scott Klement wrote:It's not clear why you're using the RPG program to change the color rather than changing it in JavaScript? Maybe you need this info in your program? Or maybe you need it to be re-drawn with the same values later?
This is just an example program I whipped up to demonstrate the issue. The program i'm intending on using it for was doing some other things as well, but I didn't want to post an example with extra irrelevant code.

I think I will just change it all to be done via JS to also omit the need to resubmit the screen.

Thanks for the help, Scott.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest