Extract specific cell data from Interactive table - Oracle-APEX - oracle-apex

I have an item P0_ITEM, I want to use a value from a particular cell in an interactive report and assign it to the item P0_ITEM, How can this be done?

Set static region ID to something like p1_ir
Define a dynamic action on click of jQuery selector
#p1_ir td
Event scope: dynamic
Execute JavaScript code
$s('P0_ITEM', $(this.triggeringElement).text());

Related

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

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.

Oracle APEX - how to read a cell from interactive grid

The same question once again but with (I hope) better explanation:
I created the most simple case:
An Interactive Grid IG with data source EMP ( table with 14 records contains Ename, Job, HireDate, Salary etc. etc.)
Text field P7_ENAME
After running it looks like below:
What I would like to do is to copy Ename from selected record of IG to P7_ENAME field .
I found several tutorials (text and video) how to do it. Most of them suggest to create dynamic action SelectionChange on IG and when TRUE add a JavaScript code something like below:
var v_ename;
model = this.data.model;
v_ename = model.getValue( this.data.selectedRecords[0], "Ename");
apex.item( "P7_ENAME" ).setValue (v_ename);
and the second step is to create another action: Refresh.
So finally I have a dynamic action with two steps : the first one is a Java script code and the second refresh function on my P7_ENAME field.
Sounds simple and it is simple to repeat/implement. A guy (I suppose) from India published a video on YouTube (https://www.youtube.com/watch?v=XuFz885Yndw) which I followed and in his case it works good. In my case it simple does not work - field P7ENAME is always empty, no errors appears. Any idea why ? Any hints, suggestion ?
thanks for any help
K.
The best way to debug and achieve what you are trying to do is as follows:
create the Dynamic action with the following setup:
-when -> selection change[interactive grid],
-selection type -> region, region -> your IG region,
-client side condition -> javascript expression: ```this.data.selectedRecords[0] != undefined```
First action of the true of the DA with the type: execute javascript code and fire on initialization is turned on, code: console.log(this.data.selectedRecords);
Run your page, and check the browser console. You should see an array of columns when you select a record from that IG as follows:
Find in that array, which sort number of the array contains the data that you want to use for the page item. Let's say I want the 3rd element which is "2694" then I should change my dynamic action's execute javascript code to:
var value = this.data.selectedRecords[0][2];
apex.item( "P7_ENAME" ).setValue (value);
The last thing I should do is add another true action (and the refresh action at the end) to the same dynamic action with type 'SET VALUE' and 'PLSQL EXPRESSION' as type, put :P7_ENAME in the expression, items to submit P7_ENAME and affected element: item / P7_ENAME as follows:

Pass column classic report value to PL/SQL

I have page with Classic Report on it (type = PL/SQL Dynamic Content). What I need it's passing one column value to PL/SQL via Dynamic Action when click on another column. It's no problem to initiate click action, but I don't know how to pass equivalent of #col_name# (not :Pxxx_item_name) to PL/SQL.
Application Express 5.0.4.00.12
I'm not sure what you're trying to pass, so I'm just going to call it "item".
In your report add a custom data attribute to the column, data-item="#COL_NAME#". This would go on the image that's getting clicked. You might need to use the HTML Expression option to set this.
Create a hidden item, P1_ITEM and set Value Protected to No.
Create a Dynamic Action that fires when you click the image in the column.
Create a True action on that DA, Action = Set Value, Set Type = Javascript Expression, the JS expression is this.triggeringElement.dataset[ "item" ], Affected Element > Selection Type = Item, Item = P1_ITEM.
Create another True action on that same DA, Action = Execute PL/SQL Code, Items to Submit = P1_ITEM, and whatever code you want in the PL/SQL code section. You can reference P1_ITEM in your code with :P1_ITEM or V('P1_ITEM').
When the DA fires, it will populate the column value into P1_ITEM, then submit that to the server where it's stored in session state, then run your PL/SQL code.

Adding dynamically selected value to LOV in Oracle Apex 5

I have problem with multi-select LOVs in Apex 5.
I want to do, in programmatic way, select values in multi-select LOV.
For example I press button and some value will be selected in LOV.
Any ideas how to do this?
If you mean a Select List item that is set to allow multiple values then your button could execute this Javascript:
$('#P123_MY_MULTI_SELECT option[value="AAA"]').attr('selected',true);
$('#P123_MY_MULTI_SELECT option[value="BBB"]').attr('selected',true);
... etc.
Alternatively, you could use a dynamic action, but it wouldn't be any simpler. It would define the affected elements using a jQuery selector:
#P123_MY_MULTI_SELECT option[value="AAA"],#P123_MY_MULTI_SELECT option[value="BBB"]
... and the action would be to execute Javascript code:
$(this.affectedElements)..attr('selected',true);
I'll describe the easiest example:
Create APEX item eg. P1_MULTIPLE
Type = Select list
Allow Multi Selection = Yes
List of Values > Type = Static Values
List of Values > Static values = STATIC:Display1;Return1,Display2;Return2
Create button eg. SET_VALUES
Create dynamic action
Event = Click
Selection type = Button
Button = SET_VALUES
Create true action within DA from step 3
Action = Set Value
Set Type = JavaScript Expression
JavaScript Expression = ['Return1', 'Return2']
Selection Type = Item(s)
Item(s) = P1_MULTIPLE
Test it.
basically, if you want to change value(s) of the multi select list you need to pass array of value(s).
With pure jQuery (without APEX DA):
$("#P1_MULTIPLE").val(['Return2', 'Return1'])

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 :)