I am using new Oracle APEX card region, I have two buttons which should be displayed depending on row data. How to achieve that?
There are 2 ways to add a button in a cards (using new card region).
Using "Actions". In this case the "server side condition" can be bound to the row data. For example if I have a card region on the EMP table the server side condition of "Item = Value" with item = ENAME (column name) and value = 'KING' would only make the button visible for the record of the employee named 'KING'
Using 'Template Directives'. This is when you display the button in one of the sections (title/subtitle/body/secondary body). To achieve this, toggle "Advanced Formatting" of the region and put your own markup in it. A button can be built using the button builder in the Universal Theme application and the display can be controlled using template directives. Note that in this case you'll have to submit using a dynamic action. Read more on template directives here or in the docs
Related
I created an apex page wherein i need to split my classic report of 50 columns into 5 tabs with 10 columns displaying in each.
So for each section, i created a static content region with template as tabs container.
Inside it as sub region i added the classic report.
Start New Row->No so that the Tab headers are all side by side.
After doing this for all 5 tabs when i run the page it shows all 5 tabs whereas i need to see the 1st tab by default and the rest only when i click on the respective tab name.
So only the tab on which i click needs to be active.
What am i implementing incorrectly here?
I would use a region display selector for this.
Create a region with template 'blank with no attributes'. This is typically placed in breadcrumb bar location, and can be configured to not 'show all'.
Now any content region with attribute 'region display selector' is shown tabulated.
Often you'll need to take care to ensure inline dialogs or other note regions don't have this attribute selected.
I am using Oracle Apex 18.2.
I have an interactive grid and a custom button to add a new row to the IG using,
apex.region("myRegionStaticId").widget().interactiveGrid('getActions').invoke('row-add-row'); then set a column's value using, $s("myColumnStaticId","2");. When I try it, it adds the first row without setting any columns' values and starts setting the value from the second row on. Even using selection-add-row or insert-record, there is always something with the first row. Here is a sample,
[https://apex.oracle.com][1]
ws = ESLAM_WS
user = forhelp
pwd = forhelppwd
app = TEST
page = Add Row on top of an IG.
After a lot of talking and testing, I've found that $s with setTimeout isn't very reliable. I've set up page 7 again to demonstrate.
If you click the Rowaddrow button twice in rapid succession (the second time before the first setValue returns), the second row will not be initialized. I'll show you a workaround for this below, but you'll
If you lower the setTimeout to, say, 10 ms, and try focusing in the Expiry Date column before clicking the Rowaddrow button, you'll find it doesn't work. This means that, while the setTimeout of 100 ms works now, it could break in the future if the IGs internal logic changed. Unlikely but who knows.
For the moment, I would say that $s can only be reliably used to set a column value in an IG for the active row. When the row-add-row action adds a new record, it does make it active, but that is done asynchronously via setTimeout. This is because the IG is based on the flyweight pattern and there are a number of async (setTimeout based) heuristics that are built in to handle focus and blur events to correctly enable and disable rows and cells as needed.
I've found the following to be the most reliable solution. Unfortunately, it's more complex than what you had before - but it was the only way I could wrangle it all together. Feel free to use it or not. See page 8 for an example.
Right-click the custom Rowaddrow button and select Create Dynamic Action. Set the Name of the DA to rowAddRow button clicked. The When settings will automatically be configured for the click event on the button.
Select the action for the new DA. Set Action to Execute JavaScript and enter the following JavaScript in the Code attribute.
addRowClicked = true; // Global used to distinguish custom button click
this.triggeringElement.disabled = true; // Disable button to serialize access
apex.region("KITCHEN_SHARE_DTL").widget().interactiveGrid("getActions").invoke("row-add-row");
Create a new Dynamic Action and set the Name to New row initialized. In the When section, set Event to Row Initialization [Interactive Grid], Section Type to Region, and Region to KITCHEN_SHARE_DTL.
Under Client-Side Condition, set Type to JavaScript expression and enter the following code in JavaScript Expression (which ensures the DA only fires for the click of the Rowaddrow button):
addRowClicked === true
Select the action for the new DA. Set Action to Set Value, Set Type to Static Assignment, and Value to 2. In Affected Elements, set Section Type to Column(s) and Column(s) to INGREDIENT_ID. This will replace the static assignment that was being done with $s. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set the Action to Set Value, Set Type to SQL Statement, and enter the following code in SQL Statement:
select MIN(EXPIRY_DATE) from stock
where ingredient_id = TO_NUMBER(:INGREDIENT_ID);
Set Items to Submit to INGREDIENT_ID and disable Escape Special Characters. In Affected Elements, set Selection Type to Column(s) and Column(s) to EXPIRY_DATE. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set Action to Execute JavaScript Code and enter the following JavaScript in the Code attribute.
addRowClicked = false; // Unset the global
$x('ADD').disabled = false; // Enable the button
Change the following code:
$s("INGREDIENT_ID","2");
with the following one:
setTimeout(function(){ $s("INGREDIENT_ID","2"); }, 100);
It seems that the IG needs a little time to render the new row before you are able to change any value.
I'm wondering if it's possible to dynamically change the interactive grid region header text. I have an IG that provides detail from a "master" report, and I'd like the HTML header text to update dynamically to display the title of the master record being displayed.
I'm guessing I'll need to create a custom dynamic action, but I'm not sure how to identify / reference the region header text element.
I appreciate any ideas.
I created a Master/Detail page based on DEPT/EMP to come up with these steps.
Give the child region a static id (I used js-ig-emps).
In the Page Designer, right-click the parent region and select Create Dynamic Action.
For the Dynamic Action, set Event to "Component Events > Selection Change [Interactive Grid]".
For the Action, set Action to "Execute JavaScript".
In Code, enter some JavaScript that updates the header of the child region using data from the parent.
Here's the code I used:
var selectedRecord = this.data.selectedRecords[0];
var selectedDept = this.data.model.getValue(selectedRecord, 'DNAME');
var newText = 'Employees in ' + selectedDept;
$('#js-ig-emps .t-Region-title').text(newText);
That assumes you're using Universal Theme. You'll need to make adjustments according to your requirements and the columns you have access to from the parent region.
Environment: Oracle APEX 5.1.2 / Oracle 12c
I'm currently using an Interactive Grid (IG) with the APEX$ROW_SELECTOR set to single record selection (i.e. radio group). What I am attempting to do, is use a Dynamic Action "Click" event off this APEX$ROW_SELECTOR, but unfortunately it's not firing when I click on the radio group selector.
I have the following questions based on the above:
How to add a Dynamic Action on row selection (APEX$ROW_SELECTOR) to fire when clicked?
When clicked, how to set a column value in session state to be used within a classic report?
Assuming the above is NOT possible with a Dynamic Action as part of an IG, how else can I perform something similar when a user selects a row with my IG?
You can search the class in the dom
.u-selector
Create a dynamic action using this class
And the result is
You need to follow the below steps:
You need to set a static class to the clickable column.
Create a new dynamic action of type "click"
The selection type would be JQuery Selector.
in the Selector field you need to fill the static class you mentioned in the column attributes.
You need to put the html id of the column as the id of the row and capture the value of it as follow in javascript:
this.triggeringElement.id -- it will capture the clicked item.
-Once you catch the value, you can set it to Page item and do whatever needed.
I'm using Application Express to build a page with a form that shows all the rows in Table A. Table A has to contain all the values from Table B that have a specific "Status".
I'm looking for a way to update Table A so that new rows with the correct status from Table B are added to Table A.
Is there a way to add a button to the page that inserts into Table A those rows? I have no problems with coding the query itself, but on Apex' Page Designer, when I add a button (which I called Refresh) to the page, I can't find a place to add the Insert Query.
Any tips?
there are several ways to do what you need, the simplest one would be to bind a dynamic action to the click event on the button.
On the button definition go to "Action when button clicked" region and on the action field select "Defined by dynamic action"
On execute validations choose "No"
Then, back on the page definition, create a dynamic action, on Event choose "Click", on Selection type choose "Button" this will make a field named button appear whit a list of the available buttons to choose.
In condition you can define a true/false evaluation. if so then you would be able to define actions to execute in both cases, if you leave it empty ("No condition") then all the actions defined will be executed.
Once defined click next and here you decide the action type, the one you need is "Execute PL/SQL Code", which will show a text field on which you can paste your code, and the parameters needed from the page.
finally you can specify if the action will have a repercussion on any kind of visual component on the page, this is for efficiency, but is not necessary.
That would be all, once created, when you click the button the code will be executed on the server.