I am developing an application which has many region in interactive report.
Now, I want to hide some of the region in the interactive report. Is it possible to do it in APEX? I am using Oracle APEX 5.1.
I Add server side condition for region of interactive report that we want to hide based on the condition.
I USE THIS CODE IN SERVER SIDE CONDITION :
Declare
l_status pls_integer;
begin
begin
select ID into l_status
from TABLE_1 where id =:ID;
exception
when others then l_status := 0 ;
end ;
if nvl(l_status ,0) = 0 then
return true;
else
return false;
end if;
end;
WHEN DYNAMIC ACTION IS TRUE THEN I USE HIDE ACTION FOR HIDE REGION BUT Does not work .
can someone help ?
A server side condition is evaluated when the page is rendered. If a component on the page is not rendered because the server side condition yielded false, it is not part of the dom and it cannot be shown using a dynamic action.
If you want to use a dynamic action to show/hide a component, then you have to hide it first (for example with an onload dynamic action).
Related
I am selecting a value from LoV.Then i am clicking a button to trigger dynamic action(When->event=click,selection type->Button,Button name).Then in Server-side Condition i am putting (rows return->select * from tab)--Its triggering as expected,But if i will change sql query (select * from tab where col=:Lov)(there is 1 record,but its not triggering).
The reason why it is not triggered, is because a server-side condition tells APEX whether or not to load the defined Dynamic Action when rendering the page.
In your first example, the query select * from tab will return rows. So when rendering the page, the dynamic action will be loaded and executed when the button has been pressed.
In your second example, including the where clause select * from tab col=:Lov, page item :lov is most likely still empty when rendering the page and therefore the dynamic action is not being loaded and doesn’t exist for the browser at the moment you press the button.
Server-side condition is not the right solution here.
If you want the dynamic action only being executed when the selected lov item also exist in a table.
In APEX 5.1 you can execute an AJAX call in your DA to check the row existence before executing the actual logic.
In APEX 19.2 you can define extra output columns in a LOV, which you can use to set an additional page item. Set that item as an indicator (Y/N) to run the DA. Then you can use the Client-side condition to determine whether or not the DA should be executed, based on the indicator.
Hope this helps. Let me know when you need further assistence with one of the two solutions.
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.
Oracle APEX QUESTION: I have a report parameters region on my Oracle APEX page with two separate checkbox items (P1_CHECKBOX_1 and P1_CHECKBOX_2) with options (A, B, C, D) and (E, F, G, H) respectively.
The user clicks a 'Submit' button to generate the various reports below based on the selection in the checkboxes.
I want to show a certain report region only if 'C' is selected in P1_CHECKBOX_1 OR 'F' is selected in P1_CHECKBOX_2. I have tried a few options through the region Server-side Condition and creating a Dynamic Action (using Item in List). I can't even seem to make the region show based on the P1_CHECKBOX_1 selections, let alone adding in the second condition with P1_CHECKBOX_2.
Can anyone help / provide an example when doing something similar?
Try to build a "SQL Expression" server side condition:
instr(':'||:P1_CHECKBOX_1||':',':'||C||':')>0
or instr(':'||:P1_CHECKBOX_2||':',':'||F||':')>0
or maybe an "Exist" server side condition:
select 1 from dual
where instr(':'||:P1_CHECKBOX_1||':',':'||C||':')>0
or instr(':'||:P1_CHECKBOX_2||':',':'||F||':')>0
This PL/SQL expression in the server-side condition should do it:
':'||:P1_CHECKBOX_1||':' like '%:C:%'
or
':'||:P1_CHECKBOX_2||':' like '%:F:%'
I have a page with two Interactive Grids. One shows Approved records. One shows Unapproved records. There is a button with processing underneath on each grid to set the selected rows to Approved/Unapproved respectively.
I want to hide these buttons based on if a user is an Approver. These values are store in some user managed tables.
I have a dynamic action on Page Load that runs the following and sets a page item to 1 / null depending on the return:
select 1 from users where upper(username) = upper(:APP_USER) and userrole = 'APPROVER';
Based on the value in the page item two dynamic actions fire on page load to set the buttons with
True=Show
False=Hide.
Client Side Condition: Item = Value: P1_PAGE_ITEM = 1
Now - on my local machine this works fine. I made the page item visible. Can see a 1 or null and the buttons are hidden/shown.
I moved this to a Development environment and now I get a warning about Unsaved Changes each time I click out of the page (doesn't happen on Local). And although I can see a 1 in the Page Item field the actions see this as False (I put an alert on to fire when true/false).
Question is: Why am I getting the unsaved changes warning on the new environment. And why would the actions see the field as FAlse.
I have compared all of the properties as best as I can and they seem identical. I have even arranged the sequence numbers to be identical in the two environments.
All thoughts welcome...
This doesn't need to be a DA that is modifying a field value, hence the alert.
Why not define a computation that executes during the render, and use that as a server side condition on your Dynamic Action?
Otherwise you've enabled a security threat, where the user can tweak some HTML to see the regions you've hidden.
I have an Interactive Report in Oracle APEX 5.1, i have several columns which i want to Hide but allow the end user to search for a text within the hidden column(s).
I have pasted below in the "Function and Global Variable Declaration" section of JavaScript for the page that contains the interactive report -
function hideColumn(id) {
$(id).remove();
}
and below in the "Execute when Page Loads" section -
hideColumn('#static-id-of-column-to-hide');
But this hides the column header ONLY, the data for the respective column is still visible. The space for the hidden column is taken up by the next column header. Also, i have tried both $(id).remove(); and $(id).hide(); , result is same.
Any suggestion?
You could use CSS instead, where your_report is the Static ID for the region, and YOUR_COL usually comes from the column alias. You can verify this by inspecting the element using the browser tool.
#your_report td[headers="YOUR_COL"]
,#your_report th#YOUR_COL
{
display: none;
}
But you might find the report doesn't always respond as expected, in regard to settling column widths.
If you do go the JS route, you should fire this in a Dynamic Action that's After Refresh of that region, not just on page load.
Try this instead of that. (into page inline CSS) It will fix your trouble with column widths maybe.
.a-IRR tr th:nth-child(X), .a-IRR tr td:nth-child(X) {
display:none;
}
where "X" is the column number what you want to hide.