Page 1 of 3
Subfile Fold, Again
Posted: Tue Apr 29, 2014 3:37 pm
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;
Re: Subfile Fold, Again
Posted: Tue Apr 29, 2014 4:23 pm
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 (37.52 KiB) Viewed 847 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!
Re: Subfile Fold, Again
Posted: Tue Apr 29, 2014 5:13 pm
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.
Re: Subfile Fold, Again
Posted: Tue Apr 29, 2014 5:38 pm
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:
...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.
Re: Subfile Fold, Again
Posted: Wed Apr 30, 2014 10:45 am
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?
Re: Subfile Fold, Again
Posted: Thu May 01, 2014 2:34 pm
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.
}
Re: Subfile Fold, Again
Posted: Fri May 02, 2014 4:12 pm
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.
Re: Subfile Fold, Again
Posted: Fri May 02, 2014 4:19 pm
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.
Re: Subfile Fold, Again
Posted: Fri May 02, 2014 4:24 pm
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.
Re: Subfile Fold, Again
Posted: Fri May 02, 2014 4:33 pm
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?