Button's OnClick Event
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Button's OnClick Event
I'm having an issue with an Button's OnClick event. I'm trying to set a the value of a text box with pui.set('myText','1'). However, when I put this code in, the button's response doesn't send a value back to the screen. Even if I set bypass validation to send data.
Any Ideas?
Any Ideas?
-
- 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: Button's OnClick Event
You cannot have both "onclick" and "response" on the same button, it is not supported, and not recommended.
If it is important to do things this way, you can create a hidden button (mark it hidden so the user can't see it), and then in the original button, have it run pui.click() to click the hidden button. That will allow the screen to be sent to RPG.
If it is important to do things this way, you can create a hidden button (mark it hidden so the user can't see it), and then in the original button, have it run pui.click() to click the hidden button. That will allow the screen to be sent to RPG.
-
- 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: Button's OnClick Event
Depending on what you want to do, it might be better to use the "onsubmit" event (record format property). This runs any time the screen is submitting (doesn't matter if it is done via the enter key, a button, or whatever else). Then your button can use the response property as normal, as the JavaScript logic can run during onsubmit.
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Button's OnClick Event
Very good Scott. Thank you.
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Button's OnClick Event
The entire objective is to control whether or not a grid is sorted based on screen input.
If the Refresh button is clicked, I want the sort removed (grid.clearState()).
if a hyperlink in the grid is clicked, I don't want the sort removed.
So, what I did was to add a hidden field on the screen called txtClearState. In the program, the first time the screen loads, I set this to '1'. On the screen's onLoad event, I check to see if the value of the field is '1' and if it is, I fire the grid.clearState() event. This works fine.
Next, based on your previous post, I removed the bound response to my btnRefresh and addded a pui.set('txtClearState','1') to the button's on click event. After which a pui.click('btnRefr') to a hidden button is fired. This button is bound to my btnRefresh indicator. Now, the txtClearState is set to '1'. I have it unhidden for testing. Also, the btnRefr event is fired and the screen is refreshed. However, the sort state is not cleared. I have tried clearState("sort") as well.
Secondly, I have a hyperlink in the grid to drill down to another level of data. When this is clicked, I don't want the sort state cleared. I want the grid to remain sorted. So I added a pui.set to the link's onClick event. This works, however the response indicator is not set on. I supposed I could hide variable in the form, set the row that was clicked using the grids onRowClick event. And use that to chain to the subfile instead of a READC.
Now that you have my objective, any ideas?
If the Refresh button is clicked, I want the sort removed (grid.clearState()).
if a hyperlink in the grid is clicked, I don't want the sort removed.
So, what I did was to add a hidden field on the screen called txtClearState. In the program, the first time the screen loads, I set this to '1'. On the screen's onLoad event, I check to see if the value of the field is '1' and if it is, I fire the grid.clearState() event. This works fine.
Next, based on your previous post, I removed the bound response to my btnRefresh and addded a pui.set('txtClearState','1') to the button's on click event. After which a pui.click('btnRefr') to a hidden button is fired. This button is bound to my btnRefresh indicator. Now, the txtClearState is set to '1'. I have it unhidden for testing. Also, the btnRefr event is fired and the screen is refreshed. However, the sort state is not cleared. I have tried clearState("sort") as well.
Secondly, I have a hyperlink in the grid to drill down to another level of data. When this is clicked, I don't want the sort state cleared. I want the grid to remain sorted. So I added a pui.set to the link's onClick event. This works, however the response indicator is not set on. I supposed I could hide variable in the form, set the row that was clicked using the grids onRowClick event. And use that to chain to the subfile instead of a READC.
Now that you have my objective, any ideas?
-
- 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: Button's OnClick Event
The clearState call should look like this:
Replace "Grid1" with the ID of your grid. It is case sensitive. It might be a good idea to add some error checking to it.
Run the code in your JavaScript debugger to make sure it's working as expected, if not note what part isn't working. Post the code that's not working along with the symptom (what you see in the debugger that's not working)
I don't understand the purpose of the txtClearState hidden textbox. Why not just check the response indicator from the btnRefr (hidden) widget so the RPG program knows you clicked refresh, and re-display the screen? What purpose does it serve to have a separate hidden textbox?
Same question with the links in the subfile. What's the purpose of having a separate textbox? Why not have the READC get the changed response indicators from the link, and act on them rather than a separate hidden variable? Does this hidden variable have another use than just checking to see if the link was clicked?
Code: Select all
getObj("Grid1").grid.clearState();
Code: Select all
var myGrid = getObj("Grid1");
if (myGrid == null) {
alert("Grid1 not found on page. Check spelling");
}
if (myGrid.grid == null) {
alert("Grid1 found, but it doesn't appear to be a subfile grid.");
}
myGrid.grid.clearState();
I don't understand the purpose of the txtClearState hidden textbox. Why not just check the response indicator from the btnRefr (hidden) widget so the RPG program knows you clicked refresh, and re-display the screen? What purpose does it serve to have a separate hidden textbox?
Same question with the links in the subfile. What's the purpose of having a separate textbox? Why not have the READC get the changed response indicators from the link, and act on them rather than a separate hidden variable? Does this hidden variable have another use than just checking to see if the link was clicked?
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Button's OnClick Event
My clearState syntax is correct.
I check the value of the hidden text box in my form's onLoad event to determine if the state should be cleared. If I just check the response, how would I tell Profound to clear the sort state.
I check the value of the hidden text box in my form's onLoad event to determine if the state should be cleared. If I just check the response, how would I tell Profound to clear the sort state.
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Button's OnClick Event
Something else I'm confused about. Should the record format's onLoad event fire the first time? It doesn't seem that it is.
-
- Experienced User
- Posts: 140
- Joined: Wed Sep 14, 2016 2:58 pm
- First Name: Mark
- Last Name: Walter
- Company Name: Paragon Consulting Services
- Contact:
Re: Button's OnClick Event
Actually, looking at the documentation, I think I answered my own question.
-
- 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: Button's OnClick Event
You told me that the clearState() wasn't working. Are you now saying that it is working?mwalter wrote:My clearState syntax is correct.
Okay, lets take a step back. Why are you sending control to the RPG program for a clearState()? My thinking was that you wanted to re-display the screen because clearState() resets the sort order, but you have to re-display the grid for the change to take effect, so I figured you were clearing it, then going back to the RPG program and having it re-display the subfile.mwalter wrote:I check the value of the hidden text box in my form's onLoad event to determine if the state should be cleared. If I just check the response, how would I tell Profound to clear the sort state.
Now you're saying that you're changing a variable, going back to the RPG program, and having the onload event clear the state. You have JavaScript code that's firing before clicking the hidden button -- why not have THAT code run the clearState() before you run pui.click()? That way, when the screen re-displays (Control comes back from the RPG) you'll see the change.
If you're saying that clearState() never works and is broken, then you need to open a support case. Forums are not for bug reports. They are for sharing ideas/techniques with other Profound UI users.
Who is online
Users browsing this forum: No registered users and 0 guests