Hide a region on initial page load, show after button is clicked - oracle-apex

I am setting up a report on a page with multiple checkbox page items and start and end date page items. The user clicks a 'Run Report' button to generate a report region below on the page.
The default selections for the checkbox items are all items selected, and the Start and End Date items have default options based SQL queries.
I want to the report region to hide on the initial page load, and then show once the user clicks 'Run Report'. I tried the following solutions:
Set region condition to 'Never' and then use a dynamic action to show the region once the button is clicked. However, I think the 'Never' condition trumps the dynamic action.
Create two dynamic actions, one on page load to hide the region and on clicking the button to show the region. However, the show DA is always overwritten once the page loads again because of the first hide dynamic action, so the region never displays.
Has anyone else run into this problem? Any solutions? Thank you!

You may like to consider the 'lazy loading' described on Maxime's blog.
https://askmax.blog/2018/05/18/lazy-loading-report/
Like you said, a server side condition will trump and DAs that are showing/hiding on the browser, as the region would never render.
If you want to hide something on entry, you can do something similar to what you described, but I'm not quite sure what you've done.
on load dynamic action to hide region (or add
style="display:none;" to custom attributes of region.)
on click of your button, show the region (do not run on initialisation), and
refresh the region.

Related

Create a button that will update a database table in apex

I am trying to create a button that will update a database table. I am using Oracle Application Express (APEX) 20.2. What I have done so far is create a regular button and then create a process that contains my PL SQL code that would update the table. The process is attached to the button by specifying in the "Server-side Condition" attribute to execute the process when the button is pressed. This has not work and would appreciate anyone who has any knowledge of doing this.
So all in all I am just looking to run PL SQL code that will update a table when the button is pressed.
This is the button
APEX Button
This is the process
APEX Process
The process is attached to the button
APEX Process
After pressing the button, this is what I see in Debug mode in runtime
Debug mode
After I press the button the current page stays in loading mode
Loading mode
Error I get after waiting for the loading tab to finish
Error pic
I also tried using a dynamic action instead of a process but it did not work as well. Please see image of how I set the dynamic action.
Dynamic action
I think you are overcomplicating things.
Have you tried simply making a dynamic action that is triggered when the button is pressed.
Then you can have the action run PL/SQL code to do whatever you need.
If however what you are trying to do is update a table on the screen, then what you should try is making the button just submit the page. Then make a process with the editable region being the table you are working on, do the code in there. And in case you have other submits on the page that you dont want to trigger the code, just put in a button pressed condition in the process.
The problem that was causing my button not to work was that I had a session in TOAD open and I did not commit my current query in TOAD's editor. I had to commit my changes in TOAD so that TOAD would not lock the rows that the code of the button in my APEX app was using/accessing. I also want to point out that my button worked without having to attach a process to it, instead the button needed a dynamic action attached to it as #TineO suggested.

Oracle APEX - setting field order validation

I have two placeholder static regions on the page with 4 fields on each region with sequence of fields set to 10,20,30, and 40 on each region respectively.
When page is submitted, the first validation shown is on the second region and not on the first. I can't seem to figure out why validations on the first region do not get triggered first. What could be the reason?
While in Page Designer, validations are visible on "Rendering" tab, next to each item.
Now, navigate to Processing tab - you'll see validations there. Rearrange them to set firing sequence.

How to send report directly to the printer?

I am using Apex 18.2. and ORDS as a printing server.
I have a master-detail page for selling items with a form on a table as the master region and an IG as the detail, joined to each other through assigning the PK to the FK IG's column.
There is another page with a report that can be queried through number of page items to get the documents with items sold in the previously mentioned master-detail page.
Whenever a user creates a document and submit the page, I will need to send the data of that document directly to the printer.
I mentioned the report page because I thought redirecting to it and assigning the PK to the corresponding page item could be a suggestion. But I know that I can create a shared component> report query too. But I do not know how could I send the data directly to the printer in either way.
I do not know if the report type - IR, CR or IG would make a difference. That's why I just referred to "report". But I'd need to know how it could be done with all types of reports.
Here is how a real-world scenario would look like,
You enter a supermarket, buy some items, go to the cashier, pay for what you've bought and get a receipt. The receipt is printed when the cashier saves the invoice.
I know this is not how web apps work, but this is the task I am facing.
I can think of branching to the report page after the invoice is saved and setting the PK value to the corresponding page item in the "search criteria" region to get the corresponding data then execute "window.print()". But there will be two problems then. 1- criteria region would be printed too, unless I hide it with a dynamic action or else. 2- The "print dialog box" of the browser will be displayed.
APEX 20.1 added native support for PDF printing of Interactive Grid regions. See this video: https://www.youtube.com/watch?v=e1yIFcEdW_o
If you can't upgrade, or if that support isn't sufficient for your needs, I suggest taking a look at APEX Office Print: https://www.apexofficeprint.com/index.html
APEX Office Print(AOP) can provide you the right solution.
Please try out the solution posted in the below link.
http://dgielis.blogspot.com/2020/01/print-pdf-from-oracle-apex-to-local.html
Few more examples:
How to print to an IP printer:
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/5034?session=13740999314649
How to print directly to a zebra printer
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/zebra-printer?session=6208952429228
(OR)
https://dgielis.blogspot.com/2020/01/printing-to-local-zebra-printer-from.html
If you are redirected to the Home page,
-> Click on examples in the left side menu.
-> Click on Print(highlighted in yellow).

How can Interactive Grid region be refreshed when region display selector changes in Oracle Apex?

I have three regions named Order Taken, Order Process and order Completed. Each of the regions are based on Interactive Grid and each regions set to on as region display selector.
Now, when I updated order-status of 481 order-no to taken-order-status(0) in order process region, then i want to show the changes occur in taken-order region.
More simply, I just wants refreshed data every-time only when i changes/switches region or changes region display selector.
Probably the easiest way would be to hide the Save buttons on the individual Interactive Grids (IGs) and instead have a page button called Save that submits the page. This will cause all IGs to be processed and the page to be reloaded, so all IGs will be up to date.
Have you tried adding dynamic actions on region display selector? You can refresh the region when that region is clicked on the region display selector.
Create a dynamic action on region display sector - on click event on the region. One dynamic action for each region.
Create a refresh action under true. and select the same region to refreshed as one clicked.
Does that help your case?
Put the below code in the Function and Global Variable Decleration Section
$('.apex-rds').data('onRegionChange', function(mode,activeTab) {
if ((activeTab.href === "#REGION_STATIC_ID")){
apex.region(activeTab.href.replace("#","")).refresh();
}
});
NOTE: Replace REGION_STATIC_ID with the static id of your region.

refresh of one report region in apex

I have page with 10 clasic reports and 10 form region (one for each report). On each form region is button with Dynamic action witch
insert data in table. My problem is how to refresh just one report after I insert data so that new data is shown in report. I tried to add another
true action in Dynamic action (refresh region) but it has no effect. Anyone had any idea? Apex version is 4.2
Thanks in advance.
One thing you can do is.
Assign Static ID to your every reports, Like 'myReport1', 'myReport2' or what ever you want (ignore if you already did).
on each button click when you are updating database,
add one more True Action with Execute JavaScipt Code in your existing Dynamic Action.
and put $('#myReport1').trigger('apexrefresh');
repeat this for all of your Reports with relevant Report ID.
This is a frustrating issue and one which I have hit a few times...
Things to check:
Report region is region type: SQL query (PL/SQL Function body returning SQL Query - cannot be refreshed using a standard refresh dynamic action).
Ensure that: id="#REGION_STATIC_ID#" is in the Report template you are trying to refresh
Navigate to: Report Attributes > Layout and Pagination: ensure that "Partial page Refresh" is set to Yes.
Ensure that: any page item values which your SQL report is based on are submitted, these can be entered under Region Source in the "Page Items to Submit" box.
In the "Attributes" in "Pagination", "Partial Page Refresh" should be "Yes". otherwise classic report does not refresh.
Check if you have selected the Template "Standard" in Section "Appearance" of your Classic Report. This solved my problem with refreshing in Apex 5.