Creating a new Element via JavaScript

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
esdaled
Profound User
Posts: 72
Joined: Fri May 08, 2009 2:43 pm
First Name: David
Last Name: Esdale
Company Name: Guardian General Insurance
City: Port of Spain
State / Province: Outside Canada/USA
Country: Trinidad and Tobago
Location: Trinidad
Contact:

Creating a new Element via JavaScript

Post by esdaled »

We are trying to add a button to a ProfoundUI screen (that is not running under Genie) via JavaScript. We were able to do this when the screen was running under Genie by using the following code:

Code: Select all

var newButton = newElement(12, 1, "input", "Trans. History");
newButton.id = 'btnTransHistory';
var newButton = getObj('btnTransHistory');
addEvent(newButton, "click", function(){
	riskTransactionHistory();
});
As newElement is Genie API, we have had to modify our code.

I have tried the following code, but the button does not display:

Code: Select all

var newButton = createNamedElement("button", "TransHistoryButton");
applyProperty(newButton,"id",'btnTransHistory');
applyProperty(newButton,"value",Trans. History');
applyProperty(newButton,"left",10);
applyProperty(newButton,"top",300);
newButton.onclick = function(){
	riskTransactionHistory();
};
Any suggestions on how to create a new Element in ProfoudUI?
User avatar
Brian
Profound Logic Staff Member
Posts: 286
Joined: Thu Apr 14, 2011 10:23 am
First Name: Brian
Last Name: May
Company Name: Profound Logic Software
Contact:

Re: Creating a new Element via JavaScript

Post by Brian »

We don't currently have a good way to accomplish this using JS in PUI. Is there a reason this must be done using JS and can't be controlled from your backend RPG? You could put the button on you screen and bind the "hidden" property so you could control it from RPG. Would this work for you?
esdaled
Profound User
Posts: 72
Joined: Fri May 08, 2009 2:43 pm
First Name: David
Last Name: Esdale
Company Name: Guardian General Insurance
City: Port of Spain
State / Province: Outside Canada/USA
Country: Trinidad and Tobago
Location: Trinidad
Contact:

Re: Creating a new Element via JavaScript

Post by esdaled »

We could do it in the RPG, but it would be a lot quicker for us to do in the JS.

We would like the button to display on 30 different screens. So the JS detects that we are on one of those screens and adds the button. The onclick event on the button would not need to interact with the RPG as it displays a window with HTML data from an AJAX request based on the value of fields which are on all 30 screens.

If you will not be adding newElement type functionality to ProfoundUI, we will develop our own equivalent JS function.
User avatar
Brian
Profound Logic Staff Member
Posts: 286
Joined: Thu Apr 14, 2011 10:23 am
First Name: Brian
Last Name: May
Company Name: Profound Logic Software
Contact:

Re: Creating a new Element via JavaScript

Post by Brian »

It should not be difficult for us to implement the newElement function in Profound UI. I just wanted to ensure that it is what you needed before investing development time. Let me see if we can get this into the next release.
User avatar
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: Creating a new Element via JavaScript

Post by Alex »

For the next release of Profound UI, we will update the newElement() API to work with Profound UI Rich Display File applications.

You will be able to use it as follows:

Code: Select all

var newButton = newElement("button", "Trans. History");
newButton.style.left = "10px";
newButton.style.top = "300px";
addEvent(newButton, "click", function(){
   riskTransactionHistory();
});
esdaled
Profound User
Posts: 72
Joined: Fri May 08, 2009 2:43 pm
First Name: David
Last Name: Esdale
Company Name: Guardian General Insurance
City: Port of Spain
State / Province: Outside Canada/USA
Country: Trinidad and Tobago
Location: Trinidad
Contact:

Re: Creating a new Element via JavaScript

Post by esdaled »

Many thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests