Cascading dynamic select list's dynamic action gets triggered when the list values changes ,not only when user select a value from the list - dynamic

I am developing an application on Oracle APEX 5.1.Here I have a dynamic select list whose value depends on a page item value on the same page. So I have added this page item in the: 'Cascading LOV Paret item' field of the select list and referred to this item in the pl/sql code of the select list.
And I have defined an 'onChange' dynamic action' for the select list which submits the page.
The problem is: This dynamic action is getting executed whenever the dynamic select list gets refreshed by the change of cascading LOV parent item value. But I need the dynamic action to execute only when the user select a value in the list.
Please help me to find out where I am going wrong!!
Thanks in advance.

Have you tried change the dynamic action to fire on select instead of on change?
According to the APEX documentation here. An onChange action fires when the LOV has been modified in some way whereas a select action fires when a user selects something in the field.
Alternatively another possible solution is in the select list properties. There is a setting called "Page Action on Selection" which can be used to submit the page when a value is selected.

Related

How to get the values of a checkbox in after trigger in PL/SQL?

I have a form for creating new events in Oracle Apex. With that form I am able to create new events just fine. But at the bottom of that form is a checkbox where the user will specify the clubs that are involved in organizing the event.
The list of values for the checkbox which you can see at the bottom of the image above is set to a sql query which selects 'club_name' and 'club_id' from 'club' table.
Now what i want to do is after the events gets successfully created, the club_id of the checked clubs with the id of the newly created event needs to be inserted into the 'club_event' junction table which related each event with their organizing club. So for that I thought of creating after trigger on events table. But I couldn't find how can I access the id's of the club selected in the plsql code. So my question is how my I do so and is my approach for relating event with organizing club fine? Thank you.
With the suggestiong from "Koen" I tried to I tries to implement it through "Process". But I am having problem in making my script work.
DECLARE
type idarray IS VARRAY(10) OF VARCHAR2(10);
ids idarray;
BEGIN
ids := apex_string.split(:P72_CLUBS, ':');
FOR id IN ids LOOP
INSERT INTO club_event
VALUES(id, P72_EVENT_ID);
END LOOP;
END;
What are the things that I am doing wrong and how may I resolve it?
You don't need a trigger for that. Use a page process instead. The values of the page item (I assume that is P1_CLUB) will be passed on page submit as a colon separated list of return values (in your case club_id). Use apex_string.split to convert the colon separated list to a pl/sql array . Loop through the array and insert/update/delete the records in/from the clubs table .
In addition to Koen's answer, if you want to view the event and also want to populate the checkbox with the checked values, you will have to set the following attributes for the checkbox page item:
Source - Type = SQL Query (return colon separated value)
SQL Query = select club_id from my_club_to_event_table where event_id = :P1_EVENT_ID
Used = Always, replacing any existing value in session state
Assuming P1_EVENT_ID is the primary key page item on that page.

APEX: Submit without refreshing the page

I have an interactive report that runs a large query, which takes about 20 seconds to execute.
There are many filter items on the APEX page, which affect the data in the report.
The report uses a PL/SQL query, which references the items on the page, to pull the data.
Since most users need to set multiple filters before submitting, I created a Run Report button which submits and refreshes the page, so users don't have to wait 20 seconds multiple times while they set multiple filters.
The problem is, some of the filters are select lists.
And these select lists are populated based on PL/SQL queries, which pull data from the database, and also reference values in other items on the APEX page as part of the queries.
So when the user selects an item in one of the select lists, I need to submit the item that was "changed" and then refresh the other filter items on the page, but WITHOUT refreshing the whole page/report.
Ajax should be able to do this, right?
How do you accomplish this?
I currently have dynamic actions that refresh individual items, and this seems to be working.
But it doesn't pull the correct data from the database to populate the select lists, because it doesn't submit the other filter items first.
So when the user selects an item in one of the select lists, I need to submit the item that was "changed" and then refresh the other filter items on the page, but WITHOUT refreshing the whole page/report.
That should be fairly simple as Select List items, under the "List of values" group of properties, contain Cascade LOV Parent item(s) property. It is used for the purpose you described.
For example, if there were select list items P1_CONTINENT, P1_COUNTRY, P1_CITY, then - when you select a continent, list of countries displays only countries on previously selected continent. You'd then put P1_CONTINENT into P1_COUNTRY list item's "Cascading LOV Parent item(s)" and that's all.
A lot of a APEX page uses AJAX to refresh parts of the page.
So it's there already :)
Anyway, for select lists you can use the "Cascading LOV Parent Item(s)" in order to let that select lists refresh whenever other items change their values.
For other item which does not have the "Cascading LOV Parent Item(s)", you need to submit the values to the session, before you can use them in some sql. You can create a dynamic action on the items that changes value, do a pl/sql expression just as a dummy
null;
and submit the items value to the session and then do a refresh of the items that needs to be refreshed...
Hope it helps :) and happy APEXing

How to referesh select list (based on SQL query) without refreshing the entire page? APEX 19.1

I have a select list based on an SQL query.
On that same page, I have a Modal dialog Interactive Grid that allows me to insert a new record on the table that that select list SQL query is referring to.
After I insert a row, then I have to reload the entire page for that option to appear on the select list.
How can I solve this problem? This is, how can I avoid having to reload the entire page?
Notice that cliente and name are referring to the same column on the same table.
It is possible to do this by means of a dynamic action on the page where is the list to be refreshed.
A :Create a dynamic action :
Event : Dialog Closed
Selection Type : Region or Item
List item Region/Item(s) : The Region or Item(s) from where to modal page was opened.
B : Associate a Refresh action
Selection : Type Region or Item(s)
Region / Item(s) : The Region or Item(s) to be refreshed.

SQApplication Express (Apex) - Displaying the result from cascading list of values (LOV) selection

I have been working on this for a while now and am stuck on finding the solution.
This is what I would like the end result to be - displaying this table below based on the selection from LOV #1 AND LOV #2:
This is what I have so far:
How do I make the page to display the result of the 2nd LOV selection into the likeness of the first picture?
In other words, after the second LOV is chosen, I would like the third part (Column Names) to be displayed in a report format instead of selection list format.
I am on Apex version: 4.2.0.00.27
You need to create a report which has your select list as a bind variable and your SQL query using the select list in the where clause. Create a dynamic action on your select list for the OnChange event. You need to refresh the report in the dynamic action when triggering the event.

How to access value of a select list control in APEX?

I have a select list and a DELETE button. When the delete button is clicked, a query is supposed to run DELETING the selected item from the database. How can I reference the selected item in the select list? I can reference the select list by :P11_ITEMS
Using Apex 4.01, I created the following example:
A page with just a select list and a delete button
I select ALLEN and press delete
and you can see ALLEN has now been deleted.
Other than creating the two items, the only other item is a Page Processing PLSQL process, called delete_emp.
The delete_emp process has the following delete statement that references the select list.
You should be able to reference your selected option by referencing your select list :P11_ITEMS. But if your session state has no current value for this item, your page processes may be out of order. Make sure you have your page process running after page submit (which saves the select list item value to the database for later use).