RichDotsonMTD wrote: ↑Tue Jan 25, 2022 9:37 am
1. Is there a way in the
pui_splash display to determine which fields were hidden on the screen being overlaid?
I'm not sure that I understand the question. I thought the problem was that they are
not hidden? Do you mean you want to call your AJAX request to see which ones were
supposed to be hidden?
RichDotsonMTD wrote: ↑Tue Jan 25, 2022 9:37 am
2. Is there a way to "remove" those widgets/fields in Javascript so they are not displayed when the screen is redrawn? I tried the removeElement('id_field') function and the document.getElementById(widget.id_name).remove method and they had the same effect.
Both removeElement() and document.getElementById() work on the current html page, they don't have any way to prevent the same element from rendering on
future pages. A bound field is the only thing that comes to mind, aside from re-hiding them when the page is re-drawn. Also, to my knowledge, removeElement() is an old 5250 routine that you probably shouldn't be using anymore. Instead, if you want to do this on the currently active screen, I would suggest using getObj() and/or applyProperty()
I think I understand the problem at a bit better, though. After Profound UI draws a screen, it runs the onload event. After the onload event, if that screen is to be overlaid by another one, it goes through and removes all of the "id" HTML attributes. It does this because HTML doesn't allow you to ever have the same ID repeated twice. So when it draws the new screen on top of the old one, there's always a chance that the new screen will have the same IDs. So it figures that once the "onload" event is complete, you no longer need IDs on the background screen, and it removes them all.
In your case, you are running an AJAX call, which by nature, runs asychronously. That means that by the time it has made it's request to the server and gotten the list of fields to hide, PUI has already proceeded to remove the IDs and has drawn the new screen that overlays it. When the AJAX function tries to hide them, they won't have IDs, so won't be hidden.
Where would I put the javascript code to "re-hide" the fields? I put it in the onLoad() event of the pui_Splash record format but the fields are still appearing.
I was thinking you'd do that in the onload of the overlaid screen. But, the fact that you need info from an AJAX request will definitely make this more complicated.
I think what you might have to do (and this is pretty ugly, imho) is create a lookup table before you submit the request. When the AJAX request completes, it would use this lookup table (rather than the ID) to locate the field to hide. That way, it doesn't matter if Profound UI has removed the id.
For example, you could create a table like this during your onload event (before running the AJAX):
Code: Select all
// define a global ("window." means global) variable to use as a lookup
// table.
if (typeof window.mtd === "undefined") window.mtd = {};
if (typeof window.mtd.elementTable === "undefined") window.mtd.elementTable = {};
// add the needed elements to the table. This should consist of all
// of the ids you might want to hide (even if you never actually hide them)
var idlist = ["myId1", "myId2", "myId3", "etc"];
for (var i=0; i<idlist.length; i++) {
var elem = getObj(idlist[i]);
if (elem != null) {
mtd.elementTable[idlist[i]] = elem;
}
}
Now you have a lookup table with all of the elements that might be hidden with the info from the ajax request. When the request completes, it can use this lookup table to find the correct element, even if it no longer has an "id' associated with it. For example (this would be part of the code inside the response function from the ajax):
Code: Select all
var elem = mtd.elementTable[idFromAjax];
if (typeof elem !== "undefined") {
applyProperty(elem, "visibility", "hidden");
elem.style.visibility = "hidden";
// extra processing may be needed for some elements, depending on
// how complex they are. For example, a grid would need to be
// re-rendered.
}
This is just to give you the idea, I haven't tried it, and there may be errors in my code.