Interactive Grid selection changed event is not firing - oracle-apex-5.1

I created a dynamic action to capture selection changed event for an interactive grid.
On True I set Action to "Execute JavaScript" and put in one line
console.log(this);
When I make a selection nothing is printed out to the console

I tried here and works, do you did something diferent that this:
Example: https://apex.oracle.com/pls/apex/f?p=145797:8
The dynamic action is showed together with your IG region?

Related

How to hide a region and unhide it on a button click in Oracle apex?

I want to hide a region and unhide it on a button click in Oracle apex, but its showing an error on false action that in when condition nothing is defined.
Can anyone please help me regarding this.
Regards,
Anshul Ayushya
A simple way to do that is to create two buttons: one to hide a region, and another to show it.
create them using default settings; nothing special
create dynamic actions for both of them
"Hide" button should have the "hide" action, it affects a "region" whose name is selected from the list of available regions
"Show" button should have the "show" action, it affects a "region" whose name is the same as for the "Hide" button
Run the page and enjoy in hiding/showing the region.
You could have a look at collapsible region.
Create a region, Appearance needs to be set to Collapsible (you can configure the options right below in Template Options). Some types of regions do not offer Collapsible (e.g. Interactive Report), but then you could just create a static content region, make it collapsible and create a subregion of the desired type. And you are done.
If you only want to have one button for showing/hiding the region, you might also use jQuerys .toggle() function. For that, add a static ID to your button and create a dynamic action with a JavaScript action that runs the following:
$("#<<STATIC_ID_OF_BUTTON>>").toggle();
This will hide/show your region on every click of the button. To load the region hidden, just add the following CSS for the region:
#<<REGION_STATIC_ID>>{
display:none;
}
With .toggle() you can also add options, such as defining a function to execute once the toggle actions has completed or the duration of the toggle animation such as:
$("#<<STATIC_ID_OF_BUTTON>>").toggle({
duration: 400,
complete: () => {"do someting here"}
});
See the jQuery documentation of the .toggle() function for a full list of options.

How to Asynchronously Show a Create New Button On a CRM Sub Grid?

I need to hide the "Add New" button on a sub grid until certain criteria are met. Calling Xrm.Page.ui.refreshRibbon will trigger my JS function defined in my Enable Rule, but I can't get the + button to show up.
Is this unsupported, or is there some methodology to get this to work?
Seems like you have to do few extra trick.
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon() however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
Ref: https://ribbonworkbench.uservoice.com/knowledgebase/articles/489288-show-or-hide-the-add-new-button-on-form-sub-grid
Arun Vinoth did find a great article to describe the issue, but actually I've found that just calling refresh on the grid itself was all that was actually required.
It's important to note, that this does not re-run the enable rules, just shows the button if the state has changed.

How to show an Oracle Apex 5 Error Message on Button Condition?

I want a condition on a button, it searches through an email field and looks for '#gmail.com' and if it fails to find it, the button's dynamic actions won't be triggered and an error message shows saying 'Must be gmail account'
Any help would be really appreciated.
I've had another idea of putting the code in the buttons dynamic actions where it has an IF statement, which works in the sense that if it isn't found then the button's dynamic actions won't work.
However, I need help showing an error message. I've researched it online and I don't understand.
You need to make following:
In button's properties choose: Action - Defined by Dynamic Action
Create new Dynamic Action with following properties:
Event - Click
Selection Type - Button
Button - choose desired button
Condition - JavaScript Expression
Value - write this code:
$x("P1_MY_EMAIL_ITEM").value.substring(
$x("P1_MY_EMAIL_ITEM").value.indexOf("#")) == "#gmail.com"
Action - Submit Page
False Action - Alert with Text - It is not a GMail account!
All checkboxes Fire on Page Load have to be unchecked!
Run the page
How it works: Dynamic action could be fired on condition. For every Dynamic Action with a condition, you can create several true actions and false actions, which are fired if the condition is true or false respectively. So you just need to create a condition, which checks user's input (compare end of a line with #gmail.com), your true action will be Submit and false action - alert.

Get value from autocomplete text field in ApEx

I want to create a dynamic action, that will set a value to an item on the page, when the value of another item (autocomplete text field) is set.
So the proccess goes like this:
Click on the autocomplete field
type some letters
choose one of the suggested values
I cannot find an event that will be executed when the selection of one of the suggested values happens. This way, I cannot see how I can read the value of the autocomplete field, once a suggested value is selected.
The change event doesn't fit my needs, it doesn't execute when one suggested value is selected.
I had the same problem, found this link: https://community.oracle.com/thread/2130716?tstart=0 and modified my dynamic action as follows to get the desired behaviour:
Event = Custom
Custom Event = result
From the link:
the problem seems to be the default behavior of the browser. When you
enter some text into the autocomplete and the list is displayed, the
focus is still in the text field. Also if you use the keyboard cursors
to pick an entry the focus will still be in the textfield. That's why
the change event of the textfield doesn't fire. It only fires if you
leave the field.
On the other side if you pick an entry with the mouse, the browser
will remove the focus from the text field for a moment (before the
JavaScript code puts the focus back), because you clicked outside of
the field. But that's enough so that the browser fires the change
event.
I had a look into documentation of the underlaying jQuery Autocomplete
widget
(http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) and
there is actually an event called "result" which can be captures if an
entry is selected from the drop down list.
Try "Lose Focus" as event. It will trigger your dynamic action when you leave the autocomplete field, i.e. your curosr is moved to another field.
This probably depends on the APEX version you are using.
In case of 18.2, because the underlying component is based on Oracle JET's "inputSearch" component, you need to use following configure to capture the select change event for text with autocomplete:
event: Custom
custom event: ojupdate
Reference:
https://docs.oracle.com/cd/E87657_01/jet/reference-jet/oj.ojInputSearch.html#event:optionChange
I turned on the browser console, then turned ApEx Developer toolbar debug, and found that, on the contrary, the "Change" event does fire upon user clicking with the mouse on one of the selections. However if the user uses keyboard (type a few letters to narrow the list down, then use down arrow key to arrive at desired value, then press enter) then the Change event does not fire, just as you say.
Moreover: even when you do get the value sent back via mouse-click initiated Change event, the value isn't the autocomplete's complete and valid value, but instead the possibly partial and wrong-case value just as typed by the user. I.e., the the change event's submission of the value precedes the autocomplete's substitution.
The answer that #VincentDeelen gave is the best alternative that I can see, although it doesn't quite give that "instantantenous synchronicity" feel. You could maybe use the "Key Down" event, but be careful with that. You could get a really excessive amount of web and db traffic as each and every keystroke (including corrections) results in another firing of the dynamic action.
Testing environment: ApEx 4.2.3 with Chrome 33 as well as IE 9.
p.s. This might be worth a mention to the ApEx development team as well.
It's not really ideal, but you could use onfocus(). I'm looking for the same thing you are, I think, a custom event that fires when the selection of a suggested value happens. I haven't found it yet though and that is my work-around for now. It will run whatever function you've created for this initially with no value, but once the selection is made it will return focus and run the function again with the right value. Like I said, not ideal but it works.
Jeffrey Kemp is right. You can set it up through a dynamic action using the custom event, result. You can also register it on page load using document.getElementById("{id}").addEventListener("result", {function}); or $("#{id}").result( function( event, data, formatted ) { //something here });.
Oracle apex 19 now added a "component event" when you create a dynamic action called "Update [Text Field with autocomplete]" - this action is fired when you select a value from the list, but not when you leave the field (similar to adding the custom event "ojupdate").

ExtJs - Triggering Column Header Sorting programmatically (e.g. with QTP)

Our team is setting up test scripts for automating interaction testing using QTP, for an ExtJS based application.
Many of our elements/objects are being detected as desired, with the exception of column header sorting triggers.
Our grid panel has remote sorting, however programatically triggering a column header "click" doesn't fire our sorting, although "click"ing manually on the column header does. I've tried mousedown and mouseup, on the column header Div, and it's children -titleEl and -textEl as well.
Any ideas?
Thanks in advance.
The simplest way would be to tell QTP to generate mouse events, this way all the events that are fired when a real human clicks the header will be fired when QTP clicks it.
As seen here
origReplayType = Setting.WebPackage("ReplayType")
Setting.WebPackage("ReplayType") = 2
Browser("B").Page("P").WebElement("column header").Click ' your script line here
Setting.WebPackage("ReplayType") = origReplayType
If this is a common occurrence you can use RegisterUserFunc to define a new DeviceClick function to your test objects.
A slightly more complex way is to debug the application and see which event triggers sorting the column and then use FireEvent with the correct event.

Resources