Get Select list Item value in IG report column for DML operation - oracle-apex

I have a Select list filter on the top of the page. I want its return value to get into any column which I create in IG report automatic DML process.
Suppose, Select list has a value "Step", when I add a row in IG report, that value should be saved into DB for one column which is hidden on UI.
I tried but sometimes it stores the value which I selected in Select list item as my last selection not the current one. Do I need to create Application item for this? Please help. TIA

In this case there is a table ig_tickes with a status column. On the page there is a page item P131_STATUS (select list) with values "OPEN" and "CLOSED". There is an interactive grid on table ig_tickets with column STATUS hidden. Functionality is that user selects a value from the select list and then clicks "Add Row".
Give the interactive grid a static id of "tickets"
Create a dynamic action on change of P131_STATUS with a true action of type "execute javascript code" and code:
var model = apex.region("tickets").call("getViews").grid.model;
model.getOption("fields").STATUS.defaultValue = apex.item( "P131_STATUS" ).getValue();
That's all there is to it.

Related

Oracle Apex 22.21 - Chart Page - Bar Type - How to return a range of date values based on user input

I have a table ORDERS which contains column ORDER_DATE. I have created a Chart as a Bar type.
Right now, the chart returns all the orders because I did not specify a Maximum Rows. The date on the x-axis and the number of orders on the y-axis.
How can I add a form for the user to select a range of dates and return only the values for those dates?
Example:
Doesn't necessarily have to be a calendar. A dropdown is fine as well. Or even a 'text' input since that is the easiest way.. I just need to know how to go about creating this feature. Your help is appreciated. Thank you.
First create a page item as date picker or some other plugin you already have to let users select a date or date range. (make sure that when user selects a date, the page item value is set by using a dynamic action or by a setting that your plugin has (set item value after selection kind of setting) )
Then create a new view with the source of your ORDERS table but it should have a where statement as it filters records by your page item such as:
select count(1)
from ORDERS
where order_date between :P1_DATE_FROM and :P1_DATE_TO
Set the source of the chart to this new view.
After user sets a value, refresh the chart by a dynamic action if it is not refreshed automatically.
In summary, the idea is to make your chart's source filtered by page items that users can change. Then refreshing the chart so that the new page item values are effective.

Use Oracle APEX LOVs to Initialize Multiple Page Items? - APEX 21.1

I understand that the default behavior of LOVs is the following:
SELECT business_desc as display_val,
business_id as return_val
FROM businesses
This attached to a select type page item P1_BUSINESS will display a list and when a list row is selected, then assign the business_id value to the page item P1_BUSINESS.
Is there a way to build a list of values to set the value of more than one page item that are not displayed? Using the below SQL:
SELECT business_desc as display_val,
business_id as return_val,
form_type,
individual_flag
FROM businesses
Where now when a user selects something from P1_BUSINESS it sets the values of that row/record as follows:
P1_BUSINESS = business_id (like it does by default)
P1_FORM_TYPE = form_type (P1_FORM_TYPE is a hidden page item)
P1_IND_FLAG = individual_flag (P1_IND_FLAG is a hidden page item)
I know I can do this with an onchange dynamic action, but just curious if can do inside the LOV or select page item (P1_BUSINESS) declaratively.
In Shared Components > List Of Values, there is an attribute "Additional Display Columns". The help text on that screen says it all Additional display columns can be defined for item types that support multiple display columns, for example the Popup LOV. For item types that do not support multiple columns, these will be ignored. If adding additional display columns ensure that the return column is included in the column list. The return column can be set to Visible No and Searchable No if you do not want it displayed to users.
Example using emp/dept sample data:
Create a list of values on table emp with return empno and display ename. Save.
Edit the LOV and click Additional Display Columns > Select Columns. Select job as additional column.
In the IG, set Visible and Searchable to "No" and Apply Changes.
On the page, create 2 page items: P1_EMPNO (type popup LOV) and P1_JOB (type Text Field)
For P1_EMPNO, pick the LOV created above as shared component > List Of Values and add JOB:P2_JOB under Settings > Additional Output. JOB is the additional column name/alias and P2_JOB is the item it should map to.
Now when you run the page, observe that P1_JOB is populated when you select a value for P1_EMPNO

How to add conditional display to Interactive Grid column if no data returned for particular column

I have an Interactive grid based on data table with columns as : HEADER_1,HEADER_2...HEADER_6.
I want conditional display of columns such that if no row is returned for a particular column, i.e. if select HEADER_6 from data --> returns null, then HEADER_6 column shouldn't show at all.
I have page items created also for each column for another requirement like P4_HEADER_1...6, so in case they can be used in this also, please suggest.
Go to column HEADER_6 in section Server-side condition choose Rows returned and add query:
SELECT 1
FROM DATA
WHERE = HEADER_6 IS NOT NULL;
Or you can use item in Server-side condition.
Column HEADER_6 will not be displayed if HEADER_6 is null.

How to perform partial refresh of page in APEX5.0

I have an APEX page where it contains multiple regions. Each region has its own drop down list (Select list) item and a bar chart. My problem is from any particular region when I select a value from the drop down list, the whole page is refreshed as I have the option Submit page set for Page Action on Selection property.
How do I perform partial refresh so that during the selection from drop down list only the bar chart for that region should be refresh and not the entire page?
Go on your select list item and change the Page Action on Selection property from Submit Page to None. Then create a dynamic action on page with the following options:
Event=Change
Selected Type=Items
Item=Your select list item
Action=Refresh
Selection Type=Region
Region=Your bar chart
Same as answer above with one trick to make it work. The value in your select list has not been submitted so will be null and not work.
Add another Dynamic action that runs before the refresh one of type PLSQL. set the code to null; then add your select list to the "items to submit".
Should work now :)

Refresh Apex 5.0 chart results with different dynamic actions on same SQL query

I have created a bar chart on APEX 5.0 where my query looks like below:
select col1 as label,col2 as value from table1 where :P3_NEW_1 = col3;
here: P3_NEW_1 the page item I have created of type "Select List".
The list of values in "Select List" page item are pre-populated in the dropdown using the "Shared component" type I have created and so far this worked fine and I am able to display the results of above query by passing the value through the page item select list.
Now I need to add 2 data pickers on the same Apex page such that I should now be able to filter the results using date picker through dynamic action.
I know that using an additional button I can create a dynamic action but my problem is how do I modify the above query such that following should happen.
During the page load, once I select a particular value from the "Select List", it should display records based on the value selected from dropdown
This I already achieved using above sql query for the bar chart.
Once the bar char is displayed, I should next be able to filter and display the results using date ranges through date pickers.
Here my problem is my bar chart query is same but I need to now pass the start_date and end_date to the same above sql query which but I am not sure how to achieve this. If I add a button for dynamic action I need to select the report region which is the "bar chart" region and here my query needs modification.
Once the bar chart display the results, at the next step how do I filter the results by having the date filters with dynamic action on the same region where bar chart was displayed. How to achieve this?
You can change the query to something like this:
SELECT COL1 AS LABEL,
COL2 AS VALUE
FROM TABLE1
WHERE :P3_NEW_1 = COL3
AND (:P3_START_DATE IS NULL
OR TO_DATE(TIME_STAMP,'YYYY-MM-DD-HH24:MI:SS') BETWEEN :P3_START_DATE AND NVL(:P3_END_DATE,SYSDATE));
Where :P3_Start_date and :P3_End_date are the Start and End date pickers and TIME_STAMP is your column where you store the date.
After modifying the query you can simply add a button where at Behavior>Action select Submit Page.
This way when you click the button, the page will be submitted and chart refreshed.
If you want to take your chart to the next level you can do a partial refresh on it. Here is a short video tutorial of partial refresh on a report but you can apply the same login on your chart.