Page 2 of 3

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 4:44 pm
by Scott Klement
Depends on the type of widget. I just re-read this thread, and I'm thinking that you're probably working with a CSS Button. Is that true?

If so, I wouldn't use pui.set, I'd use applyProperty, like this:

Code: Select all

applyProperty("btnExpand", "value", "F8 - Close");
applyProperty("btnExpand", "icon", "up arrow");

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 4:51 pm
by DaveLClarkI
That is one of the iterations I tried. The grid opens and closes without errors. But, the button text and icon doesn't change. I figured it was either because those properties were bound to RPG fields or because the button needs to be redrawn.

Code: Select all

var grid = getObj("ACTMVTRS").grid; // get pointer to grid object
grid.toggle();              // toggle the grid rows open or closed
if (grid.expanded)          // if grid now expanded
{
  applyProperty("btnExpand", "value", "F8 - Close");
  applyProperty("btnExpand", "icon", "up arrow");
}
else                        // else, grid is collapsed
{
  applyProperty("btnExpand", "value", "F8 - Open");
  applyProperty("btnExpand", "icon", "down arrow");
}

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 4:57 pm
by Scott Klement
Hmmm.... it could be that I'm wrong, then. If you want to force the widget to re-render, you can do that by changing it's field type, such as:

Code: Select all

applyProperty("btnExpand", "field type", "css button");
Most of the widgets work that way, they draw when their "field type" is changed, so changing it (even to the same value it was already set to) will cause it to re-draw.

So you can try that... but it could very well be that I'm wrong about something in the way this works in a CSS button. If setting the field type doesn't help, I may need to create a test case to try it out.

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 5:19 pm
by DaveLClarkI
OK, I put that widget redraw code in there but the button text and icon still don't change. So, it must be the fact that those properties are bound to RPG fields which prevents them from being changed directly via applyProperty(). Anything else?

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 5:34 pm
by Scott Klement
Hmmm... I set up a test case, and it works fine for me.

Please make sure you are using the button's "id" property on the applyProperty() call (not the bound field name). Also, it's case-sensitive, so be sure the upper/lower case matches exactly.

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 5:37 pm
by DaveLClarkI
mpilo0 wrote: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.
mpilo0, I tried your suggestion and that is not working, either. I created two hidden text boxes and bound their "value" property each to the same RPG fields as the button in question. Then I set their value instead the button properties and do the redraw just for good measure. No dice.

Code: Select all

var grid = getObj("ACTMVTRS").grid; // get pointer to grid object
grid.toggle();              // toggle the grid rows open or closed
if (grid.expanded === true)  // if grid now expanded
{
//applyProperty("btnExpand", "value", "F8 - Close");
//applyProperty("btnExpand", "icon", "up arrow");
  pui.set("txtF8FOLDTEXT", 'F8 - Close');
  pui.set("txtF8FOLDICON", 'up arow');
}
else                        // else, grid is collapsed
{
//applyProperty("btnExpand", "value", "F8 - Open");
//applyProperty("btnExpand", "icon", "down arrow");
  pui.set("txtF8FOLDTEXT", 'F8 - Open');
  pui.set("txtF8FOLDICON", 'down arow');
}
applyProperty("btnExpand", "field type", "css button"); // redraw

Re: Subfile Fold, Again

Posted: Fri May 02, 2014 5:49 pm
by DaveLClarkI
Scott Klement wrote:Hmmm... I set up a test case, and it works fine for me.

Please make sure you are using the button's "id" property on the applyProperty() call (not the bound field name). Also, it's case-sensitive, so be sure the upper/lower case matches exactly.
I did a copy-n-paste from the id field of the button into the JavaScript code for the onclick event of that same button. Still not working.

Re: Subfile Fold, Again

Posted: Mon May 05, 2014 1:16 pm
by DaveLClarkI
I found the problem... I put alerts in the code for the grid.expanded property and it is coming up "undefined" so that explains why the button text is not changing -- because the answer to the if-condition is always false.

What is the correct property name? Thanks.

Re: Subfile Fold, Again

Posted: Mon May 05, 2014 2:57 pm
by DaveLClarkI
Well, I ran it through Firebug to look at the properties on the grid and there isn't an exposed property that seems to fit the bill. There are several obfuscated property names with true/false values but, not knowing which one, I figured that is what you're going to tell me -- that the needed property is not exposed and would have to be done in a future release.

In the meantime, I created a workaround to capture the indicator coming from RPG in my screen's onload event:

Code: Select all

window.WISEsfl_Expanded = (pui.get('txtExpanded') == 'true');
Then, in my button's onclick event I did the following and all is working as desired.

Code: Select all

var obj = getObj("ACTMVTRS").grid; // get pointer to grid object
if (window.WISEsfl_Expanded === true)  // if grid is expanded
{
  obj.collapse();           // then collapse the grid rows
  window.WISEsfl_Expanded = false; // reverse my internal flag
  applyProperty("btnExpand", "value", "F8 - Open");
  applyProperty("btnExpand", "icon", "down arrow");
}
else                        // else, grid is collapsed
{
  obj.expand();             // so expand the grid rows
  window.WISEsfl_Expanded = true; // reverse my internal flag
  applyProperty("btnExpand", "value", "F8 - Close");
  applyProperty("btnExpand", "icon", "up arrow");
}

Re: Subfile Fold, Again

Posted: Mon May 05, 2014 10:33 pm
by Scott Klement
That's very strange... I can see the "expanded" property in Firebug...
expanded.png
expanded.png (8.83 KiB) Viewed 729 times
Not sure why it'd be different for you? I'm running Profound UI 4.8.4.