Conditional editing for output fields?
-
- Profound User
- Posts: 56
- Joined: Tue Jan 20, 2015 4:28 pm
- First Name: Raymond
- Last Name: Marsh
- Company Name: Cracker Barrel Old Country Sto
- Phone: 615-235-4215
- Address 1: PO Box 787
- City: Lebanon
- State / Province: Tennessee
- Zip / Postal Code: 37088
- Country: United States
- Contact:
Conditional editing for output fields?
One can replace the value property of an output field with a static value such as "Master Files"
The issue is on a dynamic menu where the value can change I cannot simply use a static value. What I would like to do is change "Master Files.........." to "Master Files" by somehow removing the ".........."
Can this be done?
Thanks.
The issue is on a dynamic menu where the value can change I cannot simply use a static value. What I would like to do is change "Master Files.........." to "Master Files" by somehow removing the ".........."
Can this be done?
Thanks.
- Alex
- Profound Logic Staff Member
- Posts: 233
- Joined: Fri Jan 04, 2008 12:10 pm
- First Name: Alex
- Last Name: Roytman
- Company Name: Profound Logic Software
- Contact:
Re: Conditional editing for output fields?
On a specific field and property, you can specify "js:" or "script:" followed by a JavaScript expression. For example, the following replaces all dots in a field with empty spaces:
If you need to do this globally on a screen (or on all screens within an application), you could write a script to loop through all fields on the screen and do the replacement. This would normally go into your custom.js file. The code for something like that would look as follows:
Code: Select all
js: value.replace(/\./g, "");
Code: Select all
var fields = getOutputFields();
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = get(field.id);
value = value.replace(/\./g, "");
pui.set(field.id, value);
}
-
- Profound User
- Posts: 56
- Joined: Tue Jan 20, 2015 4:28 pm
- First Name: Raymond
- Last Name: Marsh
- Company Name: Cracker Barrel Old Country Sto
- Phone: 615-235-4215
- Address 1: PO Box 787
- City: Lebanon
- State / Province: Tennessee
- Zip / Postal Code: 37088
- Country: United States
- Contact:
Re: Conditional editing for output fields?
That worked great. I entered the second example code in the onload property of the screen. Is that the best way to do this?
- Alex
- Profound Logic Staff Member
- Posts: 233
- Joined: Fri Jan 04, 2008 12:10 pm
- First Name: Alex
- Last Name: Roytman
- Company Name: Profound Logic Software
- Contact:
Re: Conditional editing for output fields?
Putting into the onload event should work without problems.
But if you needed to make this reusable for other screens, you could put the code into cusotm.js as a function, like this:
The in the onload event, you would simply specify:
Your custom.js file is located in the following IFS directory: /www/profoundui/htdocs/profoundui/userdata/genie skins/[The Name Of Your Skin]
But if you needed to make this reusable for other screens, you could put the code into cusotm.js as a function, like this:
Code: Select all
function replaceDots() {
var fields = getOutputFields();
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var value = get(field.id);
value = value.replace(/\./g, "");
pui.set(field.id, value);
}
}
Code: Select all
replaceDots();
-
- Profound User
- Posts: 56
- Joined: Tue Jan 20, 2015 4:28 pm
- First Name: Raymond
- Last Name: Marsh
- Company Name: Cracker Barrel Old Country Sto
- Phone: 615-235-4215
- Address 1: PO Box 787
- City: Lebanon
- State / Province: Tennessee
- Zip / Postal Code: 37088
- Country: United States
- Contact:
Re: Conditional editing for output fields?
Thanks again Alex.
I am noticing some changes in areas where there are no dots. For example text fields that were centered are now left justified. As if the spaces were removed. Also, the sub-file border only in the center of the screen went from solid blocks to underscores.
I am noticing some changes in areas where there are no dots. For example text fields that were centered are now left justified. As if the spaces were removed. Also, the sub-file border only in the center of the screen went from solid blocks to underscores.
- Alex
- Profound Logic Staff Member
- Posts: 233
- Joined: Fri Jan 04, 2008 12:10 pm
- First Name: Alex
- Last Name: Roytman
- Company Name: Profound Logic Software
- Contact:
Re: Conditional editing for output fields?
Our get() API trims blanks spaces. Try using getElementValue() instead of get(). That should not trim the spaces.
Here are the docs for these API:
http://www.profoundlogic.com/docs/displ ... %28+id+%29
http://www.profoundlogic.com/docs/displ ... %28+id+%29
Here are the docs for these API:
http://www.profoundlogic.com/docs/displ ... %28+id+%29
http://www.profoundlogic.com/docs/displ ... %28+id+%29
-
- Profound User
- Posts: 56
- Joined: Tue Jan 20, 2015 4:28 pm
- First Name: Raymond
- Last Name: Marsh
- Company Name: Cracker Barrel Old Country Sto
- Phone: 615-235-4215
- Address 1: PO Box 787
- City: Lebanon
- State / Province: Tennessee
- Zip / Postal Code: 37088
- Country: United States
- Contact:
Re: Conditional editing for output fields?
Thanks again Alex.
It is still doing the same thing. I've played around with various methods and I can get js to replace a '.' with a space in a string but not in 5250 output field. I don't know why the behavior is different. It still is replacing leading blanks and changing part of the subfile boundry. Those areas have no dots so I'm not sure what is going on there.
It is still doing the same thing. I've played around with various methods and I can get js to replace a '.' with a space in a string but not in 5250 output field. I don't know why the behavior is different. It still is replacing leading blanks and changing part of the subfile boundry. Those areas have no dots so I'm not sure what is going on there.
-
- 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: Conditional editing for output fields?
Ray, can you post your modified version of replaceDots() so we can see what it looks like now?
-
- Profound User
- Posts: 56
- Joined: Tue Jan 20, 2015 4:28 pm
- First Name: Raymond
- Last Name: Marsh
- Company Name: Cracker Barrel Old Country Sto
- Phone: 615-235-4215
- Address 1: PO Box 787
- City: Lebanon
- State / Province: Tennessee
- Zip / Postal Code: 37088
- Country: United States
- Contact:
Re: Conditional editing for output fields?
The "if" statement is to target only specific output fields on the screen. I'm not sure it is still necessary but this is working.
Code: Select all
function replaceiDots() {
var fields = getOutputFields();
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var str = field.id;
if ((str.split("_")[2] == "43") || (str.split("_")[2] == "4")) {
fields[i].innerHTML=fields[i].innerHTML.replace(/\ \./mgi," ");
}
}
}
- Alex
- Profound Logic Staff Member
- Posts: 233
- Joined: Fri Jan 04, 2008 12:10 pm
- First Name: Alex
- Last Name: Roytman
- Company Name: Profound Logic Software
- Contact:
Re: Conditional editing for output fields?
It's not apparent to me what the problem might be. It seems like your version of the code should work. Perhaps you could post a JSON capture of your screen here, so that we can try it on our system. To get the capture, navigate to the screen and press Ctrl-F9. Thanks.
Who is online
Users browsing this forum: No registered users and 4 guests