Hidden input textbox in JS not returning value to RPG

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
marcpassmoor
New User
Posts: 2
Joined: Tue Oct 02, 2018 2:15 pm
First Name: Marc
Last Name: Passmoor
Company Name: Protective Life
State / Province: Georgia
Country: United States
Contact:

Hidden input textbox in JS not returning value to RPG

Post by marcpassmoor »

To Whom It May Concern,

I have written a function, "getGridSortProperties", that it being performed within the OnSubmit of the CTL record format.
It correctly returns a structured return value containing 3 values; a Column List, an Order List, and a Direction List.
I am attempting to return the "GridSortProperties" for 2 grids; SFLC80 and SFLC20.
I defined, in the Visual Designer, 6 textbox elements with input CSS and named them; C80COLLIST, C80ORDLIST etc. as seen below.
The values appear to be correctly assigned via pui.set because I later reference them in the alert keyword.

let C80Lists = getGridSortProperties('SFLC80');
pui.set("C80COLLIST",C80Lists.sortColList);
pui.set("C80ORDLIST",C80Lists.sortOrdList);
pui.set("C80DIRLIST",C80Lists.sortDirList);
let C20Lists = getGridSortProperties('SFLC20');
pui.set("C20COLLIST",C20Lists.sortColList);
pui.set("C20ORDLIST",C20Lists.sortOrdList);
pui.set("C20DIRLIST",C20Lists.sortDirList);
if (C80Lists.sortColList != ""
|| C20Lists.sortColList != "") {
alert(
'Grid SFLC80'
+ '\nColumn List: ' + getElementValue("C80COLLIST")
+ '\nOrder List: ' + getElementValue("C80ORDLIST")
+ '\nDirection List: ' + getElementValue("C80DIRLIST")
+ '\n'
+ '\nGrid SFLC20'
+ '\nColumn List: ' + getElementValue("C20COLLIST")
+ '\nOrder List: ' + getElementValue("C20ORDLIST")
+ '\nDirection List: ' + getElementValue("C20DIRLIST")
);
};

However, when the CTL record format in which these 6 DIV textbox elements reside is read in by the RPG program the values in the returned data structure for these elements are blank. Am I missing something?

The purpose of the function is to allow client-side sorting to be performed (by NOT specifying the column sort response/field name sort response property and NOT the specifying return sort order property) but still pass back the response information to the RPG program so it can perform any task where that information would be useful.

Regards,
Marc Passmoor

Revolos
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: Hidden input textbox in JS not returning value to RPG

Post by Scott Klement »

You're doing this in the onsubmit event? The problem with that is that the response to send to the IBM i has already been determned before onsubmit is called. Therefore, calling pui.set() in onsubmit won't make any difference.

If you want to do this from the onsubmit event, you'll have to change it in the response object directly. If onsubmit is a function (rather than code typed into the 'onsubmit' field) it will be passed a parameter with this response object, you can then set the values therein.

There's an example of changing data in the onsubmit event here... take a look at the last example on this page where it clears the SEARCHDATA field:
https://docs.profoundlogic.com/display/ ... bmit+event

Note that when you change it in the onsubmit event like the above example, you must use the record format and bound variable names in uppercase. (This is different from the widget ids that pui.set() uses.)
marcpassmoor
New User
Posts: 2
Joined: Tue Oct 02, 2018 2:15 pm
First Name: Marc
Last Name: Passmoor
Company Name: Protective Life
State / Province: Georgia
Country: United States
Contact:

Re: Hidden input textbox in JS not returning value to RPG

Post by marcpassmoor »

Thank you so much Scott. Your response was clear and allowed me to successfully implement my enhancement.
How the relevant response fields are updated from the OnSubmit event is shown below.
The values are now available in the RPG program.

All of the following is coded within the OnSubmit event of the CTL record format:

...existing GetGridSortProperties function

// new response code follows
function setResponse(response) {
response["CTL.C80COLLIST"] = C80Lists.sortColList;
response["CTL.C80ORDLIST"] = C80Lists.sortOrdList;
response["CTL.C80DIRLIST"] = C80Lists.sortDirList;
response["CTL.C20COLLIST"] = C20Lists.sortColList;
response["CTL.C20ORDLIST"] = C20Lists.sortOrdList;
response["CTL.C20DIRLIST"] = C20Lists.sortDirList;
};

let C80Lists = getGridSortProperties('SFLC80');
let C20Lists = getGridSortProperties('SFLC20');
setResponse;
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest