Subfile Fold, Again

Use this board to ask questions or have discussions with other Rich Displays users.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Subfile Fold, Again

Post by DaveLClarkI »

I've got most of a subfile fold rich display process working; but, there are still just a couple of quirks...

One of those is that because I am using your toggle() function, my function key doesn't submit back to the RPG program so that it can change the text of the function key to reflect the inverse of the current subfile fold mode. Now, it is not necessarily a bad thing that my function key doesn't perform a submit back; however, the function key text does need to change accordingly. So, how can I detect the current subfile mode using JavaScript?

That's one... The other is that I can't seem to get my RPG code to be able to set the desired subfile fold mode upon rebuilding the screen. I've bound indicator fields to both the "expanded" and "return mode" properties and am interpreting them in RPG as follows. Is this not correct? (Note that the "return mode" property is bound to the COLLAPSED indicator.)

Code: Select all

       if Screen.COLLAPSED = *off;     // if grid is currently expanded
         Screen.EXPANDED = *on;        // indicate expanded mode is on
         Screen.F8FoldText = 'F8 - Close'; // set button text for collapse
         Screen.F8FoldIcon = 'up arrow';   // and set associated icon
       else;                           // else
         Screen.EXPANDED = *off;       // indicate expanded mode is off
         Screen.F8FoldText = 'F8 - Open';  // set button text for expand
         Screen.F8FoldIcon = 'down arrow'; // and set associated icon
       endif;
siavash
Profound User
Posts: 30
Joined: Mon Apr 01, 2013 9:50 am
First Name: Siavash
Last Name: Askari
Company Name: Erb Transport
City: New Hamburg
State / Province: Ontario
Country: Canada
Contact:

Re: Subfile Fold, Again

Post by siavash »

For your second problem regarding the collapse and expand function of the grid, I recommend to do this.
Bind all of the "expanded", "collapsed" and "return mode" properties to program fileds.
help1.jpg
help1.jpg (37.52 KiB) Viewed 845 times
And then this will be your RPG codes to control the collapsed/expanded function of your grid.

Code: Select all

If EXPCOLLRET = *Off;                                                                  
     GridExpand = *On;                                                                    
     GridCollap = *Off;                                                                   
Else;                                                                                  
     GridExpand = *Off;                                                                   
     GridCollap = *On;                                                                    
EndIf;
This could be your converted code with my method. :)

Code: Select all

if Screen.EXPCOLLRET = *off;     // if grid is currently expanded
         Screen.GridCollap = *Off;       // Set the indicate collapsed to Off
         Screen.GridExpand = *On;        // indicate expanded mode is on
         Screen.F8FoldText = 'F8 - Close'; // set button text for collapse
         Screen.F8FoldIcon = 'up arrow';   // and set associated icon
else;          // else
         Screen.GridCollap = *On;       // Set the indicate collapsed to On
         Screen.GridExpand= *off;       // indicate expanded mode is off
         Screen.F8FoldText = 'F8 - Open';  // set button text for expand
         Screen.F8FoldIcon = 'down arrow'; // and set associated icon
endif;
Hope that helps!
Siavash Askari
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Subfile Fold, Again

Post by DaveLClarkI »

So, you're saying that I can't use either the "expanded" or the "collapsed" properties -- but that I have to use both? If so, that seems like overkill and is not the way the associated 5250 keywords work.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Subfile Fold, Again

Post by DaveLClarkI »

DaveLClarkI wrote:One of those is that because I am using your toggle() function, my function key doesn't submit back to the RPG program so that it can change the text of the function key to reflect the inverse of the current subfile fold mode. Now, it is not necessarily a bad thing that my function key doesn't perform a submit back; however, the function key text does need to change accordingly. So, how can I detect the current subfile mode using JavaScript?
OK, for now, I've removed the toggle() function from the button:

Code: Select all

getObj("ACTMVTRS").grid.toggle();
...to confirm that the code in my RPG program correctly sets the button text and icon according to the subfile mode. That works. So, I'd still like to know how to detect the current subfile mode using JavaScript. This will allow me to get alternating button text without having to take a round-trip to the server to do so. Thanks.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Subfile Fold, Again

Post by DaveLClarkI »

Well, I had tried binding and setting both the "expanded" and "collapsed" properties, but I was still having the same problem. I finally found the source of my problem and then went back to binding and setting just the "expanded" property. All is working well, now, on that front. So, the following code is good -- which has the "return mode" property bound to the COLLAPSED indicator:

Code: Select all

       if Screen.COLLAPSED = *off;     // if grid is currently expanded
         Screen.EXPANDED = *on;        // set expanded mode on
         Screen.F8FoldText = 'F8 - Close'; // set button text for collapse
         Screen.F8FoldIcon = 'up arrow';   // and set associated icon
       else;                           // else
         Screen.EXPANDED = *off;       // set expanded mode off
         Screen.F8FoldText = 'F8 - Open';  // set button text for expand
         Screen.F8FoldIcon = 'down arrow'; // and set associated icon
       endif;
Otherwise, I'm using the following RPG code to toggle the subfile mode -- in conjunction with the above code:

Code: Select all

         when (Screen.F8Fold = *on);   // if F8 key...
           if Screen.COLLAPSED = *on;  // and subfile currently collapsed
             Screen.COLLAPSED = *off;  // then, turn off collapsed mode
           else;                       // else
             Screen.COLLAPSED = *on;   // turn on collapsed mode
           endif;
That is working well, too. However, I would still like to know how to detect the current subfile mode in JavaScript so that I don't have to make a round trip to the server just to get the correct function key text.

Any assistance on this issue?
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: Subfile Fold, Again

Post by Scott Klement »

To detect the current subfile mode from JavaScript, you can do:

Code: Select all

   if ( getObj("TheGrid").grid.expanded == true ) {
      //currently expanded
   } 
   else {
      // currently collapsed.
   }
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Subfile Fold, Again

Post by DaveLClarkI »

Thanks for that.

Now I need to know how to set the value of a bound RPG field using JavaScript? In other words...

The button I am using for toggling the subfile has its "value" and "icon" properties bound to RPG fields. This allows the RPG code to set those values appropriately when sending the screen to the browser. But, if I'm going to use JavaScript code to also detect and change the grid expanded/collapsed state, then my JavaScript code also needs to set the "value" and "icon" properties appropriately. I can't just remove the binding because then RPG could no longer control this. So, with those bindings in place, how can I use JavaScript to change the value of those RPG fields? Thanks.
mpilo0
Profound User
Posts: 49
Joined: Wed Jan 08, 2014 11:49 am
First Name: Michael
Last Name: Pilote
Company Name: Oceanex
Phone: (514) 875-8558
State / Province: Quebec
Country: Canada
Contact:

Re: Subfile Fold, Again

Post by mpilo0 »

I've had the same problem on other properties I wanted to set in Javascript. The best way that i have found to do this is to simply add a hidden textbox/checkbox to your screen where you store the value giving the textbox/checkbox the same binding field as the property.

If there is a better way feel free to let me know i will change my programs to use the better solution.
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: Subfile Fold, Again

Post by Scott Klement »

Dave,

You should be able to change these with applyProperty() or pui.set(). Each time the screen is displayed from RPG (via EXFMT or WRITE/READ, etc) the values of these properties will come from the bound fields... initially, anyway. Your JS code can use applyProperty() or pui.set() to change those settings. The only reason (that I can think of) that this would be a problem is if you wanted the changed data to be sent back to the RPG program. But, I don't think that'll work here anyway, since I think these properties are considered "output-only" from the RPG program's perspective.

From your example, it looks like the expanded/folded state of the subfile is the only criteria used to determine what the text/icon should be, so it seems like this should work well enough.

There is a more complicated solution that we could use if you needed the data to be submitted back to RPG... but it doesn't seem like that should be needed here.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Subfile Fold, Again

Post by DaveLClarkI »

Nope, don't need to send the changes back to RPG. But, I couldn't get pui.set() to work. What should it look like?

Button id is btnExpand
Value bound to F8FOLDTEXT
Icon bound to F8FOLDICON

Then, do I need to refresh (redraw) the button to pick up the changes?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest