Javascript dynamic conditional onclick event - javascript

I have an ASP.NET gridview, with the code below (modified from another stackoverflow question) to make the row clickable.
e.Row.Attributes("onclick") = Me.Page.ClientScript.GetPostBackClientHyperlink(Me.gvPricingGrid, "Select$" & e.Row.RowIndex)
I also have a button that, when clicked, flips a boolean held in the session (accessed through a code-behind property), and makes visible some textboxes in each row for updating the row. The property is called IsEditingProperty
What I want is for the onclick to work as it does now when IsEditingProperty = False, but do nothing when the property = True. I have tried the below, but the property is evaluated at render, rather than when the click actually occurs.
e.Row.Attributes("onclick") = "if (""<% IsEditingProperty() %>"") " & Me.Page.ClientScript.GetPostBackClientHyperlink(Me.gvPricingGrid, "Select$" & e.Row.RowIndex)
Is there a way to make this happen?

I ended up dealing with this by realizing that rowCreated happens on postback simply adding the check against the property there.

Related

Preventing Apex Button Double click

Hi I have a button that inserts empty records into an interactive grid. I want to prevent the user from being able to double click that button because it populates duplicate rows. I have a server side argument that says if there are rows the button does not appear however they are still able to double click the Populate_tables button before it vanishes. If there are any other solutions to this please sound off. I've tried everything from javascript to server-side but they are still able to double click no matter what. Here are the before and after pictures of the table.
$('#btnPopulateTbl').dblclick(function(e){
e.preventDefault();
});
The above code prevents the double click for a button. This is in jQuery.
Oracle Apex does not offer this functionality as a setting or etc.
However you can use
$('#button').click(function(event) {
if(!event.detail || event.detail == 1){
// This will be executed once even user clicks multiple times
}
});
Note that your selector must be the id or the class you provide to this button.
By default 'add row' button's classes are:
class="a-Button a-Toolbar-item js-actionButton"
Another solution would be to have apex handle this. Suppose this is on page 1.
Create a page item P1_POPULATE_ROWS_CLICKED with a default value of 'N'
In the page process that populates the table, add the following line before the actual load:
:P1_POPULATE_ROWS_CLICKED := 'Y';
Add a condition to the page process that populates the table of "Item not equal to value", P1_POPULATE_ROWS_CLICKED , Y
Yet another solution is to only execute the insert statement if no rows exist with that condition yet. I can't show you how to do it because you didn't show how the table is populated but happy to do so if you edit your question. This last option is propably the most suitable.

Two way binding for checkbox inside an accordion not workiing

In my angular 1.5 html5 application, I have an accordion group and inside it's body I have Couple of check-boxes. Since direct scope binding will not work inside accordion, I'm using ng-click event as attached.
This works as expected, I'm getting click events with correct value.
I have another reset button on screen, when user clicks this button I have to reset all filters including the checkbox inside the accordion. Even after I reset the model value to false, checkbox still shows as checked. I know this is because the binding is not there.
How can I update the checkbox value from javascript. Is there any angular way. I'm not a big fan of JQuery.
Regards,
Nixon
We faced a similar issue with the data bindings while using accordian.
Instead of using directly model variable, we created an object of it.
For eg, instead of using $scope.includeLocalParties, try using $scope.checkbox.includeLocalParties.
Also initialize it in your controller. Something like this:
$scope.checkbox = { includeLocalParties : false};
Hope it helps!

Current TabPanel ID in onClientLoad CSJS

I have client sided code in the onClientLoad event of my form that governs field hiding. Problem is, it depends on values in the first tabPanel. If I switch to the second tabPanel, it stops working. I can no longer switch back to any other tabPanel.
How can I within the onClientLoad event using CSJS identify which panel I currently am on?
In a tab panel whenever you switch between tabs the fields are recalculated.
So, I would rather suggest you to put a visibility formula on field instead.
Make sure all tab panels have a nice id. Then in your script block you can add something like:
var t1 = dojo.byId("#{id:tab1}");
if (t1) { // do your stuff }
Does it work for you?

Conditionally do a partial refresh on an XPage

I have an application that runs a timer script that does a click on an action button when it times out. The action button is hidden by display:none. on the action button I do a partial refresh on panelButtonBar from the onClick event. This all works great except part of what the onClick event does is sets a viewScope variable based on the condition of the document. The viewScope variable is vsIsLocked and can be either true or false. If the value is true I don't want the panelButtonBar refreshed. I created a field that does nothing called dummyField and added the following to the definition of the partial refresh:
(viewScope.get("vsIsLocked")) ? "dummyField" : "panelButtonBar"
by putting dBar.info statements in the code that is by the onClick of the action Button I know that it is running on schedule, I also know that the value of vsIsLocked has changed from true to false, but the panelButtonBar does not refresh. As I said if I take the conditional statement out and just do a partial refresh of panelButtonBar the refresh works, the conditional partial refresh does not. I believe my js correct. I tried:
(viewScope.get("vsIsLocked")) ? "" : "panelButtonBar"
but then the partial refresh seems to run as a total refresh.
You might be a little caught in "what gets refreshed when". The (viewScope.get("vsIsLocked")) ? "dummyField" : "panelButtonBar" sits in your hidden button and gets computed when that button refreshes. When you "press" the button however you either refresh the dummyField or the panelButtonBar, but not the button itself. So your condition doesn't get evaluated.
You can try put your hidden button into the panelButtonBar or target your refresh at something that includes both.
Update
The target property is only evaluated on page load, so you would need to have one button each for your refresh targets hard wired and compute the rendered property. So when it refreshes a different button is sent to the browser each time. You could use a custom control with a parameter array for the targets, so you only have one control in your UI

Onclick event with an argument = Not implemented?

Hoping for some advice here, I'm quite new to javascript and coding in general so I'm sure there are better ways to do what I need, however any help much appreciated ....
I have a piece of javascript that creates a table, the amount of rows being dynamic.
When I call the javascript I'm passing a few bits of info over, and one of these is an array. The array contains in each element a long string of text.
So I create the table with X rows showing some identifying data. I also create a radio button for each row with an on click event. The idea being that when the user clicks on the radio button, then the long string from the array element will be displayed in a separate text box.
I have managed to get to the point that the table is created and that when the radio button is selected the onclick event fires and loads a piece of data into the txt box. However that piece of data is hardcoded (txtbox.value=array[1])
What I'm now trying to do is load the relevant string from the array, depending on what radio button is clicked.
If i change my onclick event to onclick=function(ID) and my function to function(ID) I'm getting an error 'Not implented'
It appears to be generated from the onclick event rather than the function ...
The following works :
R1.onclick=clicktest;
function clicktest()
{
txtbox.value=array[1]
}
The following generates the error
R1.onclick=clicktest(1);
function clicktest(id)
{
txtbox.value=array[id]
}
Apologies if this isn't so clear.
Using this code
R1.onclick=clicktest(1);
You're executing clicktest(1) and assigning the result as event handler.
You could change it by this in to make it work
R1.onclick = function() { clicktest(1) };

Categories

Resources