Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
Keeping a running total in a page item when checkbox in classic report is checked or unchecked ...

Greetings:
I'm using:
ORACLE APEX Version: 21.2.1
ORACEL DB Version: 19.0.0.0
My question is;
If I have a classic report in ORACLE APEX with a checkbox in the first column, and I want to keep a running total of the Amount column in the report when the checkbox is checked in a display-only page item above the report. I also want to subtract from this running total if a user unchecks the check box. How do I go about accomplishing this?
To word it another way: After the report is queried, the running total in the page item should be zero. As they check the boxes in the first column, the Amount in another column is added to the display-only page item. If the user unchecks the box, it subtracts from the total.
Thanks,
Stan
Best Answer
-
You're the man Joe! That was the issue. Thanks so much for your help!
Answers
-
Hello bondurs,
Why you don't use Interactive Grid ?
There is a useful example in IG Cookbook - Page 5.
-
Thanks for the response Hamza. I will take a look at that. I would prefer to use the classic report though, since my users are familiar with that type of report and the way it works regarding sorting and downloading CSV files.
-
I will give you my ever unpopular JavaScript approach for doing this, @bondurs. I do not know of another way to do this if you're truly set on using the Classic report.
You'll need to add 2 classes. So, on the column attributes in the Column Formatting section under CSS Classes... On the checkbox column, add a class of sumCheckBox. On the column containing the amount you want to sum, add a class of sumAmount.
You will also need to give your Classic Report region a value for Static ID. For this example, we'll name it CLICK_SUMMER_CR.
We'll assume your Page Item is named: P01_SUMMED_AMOUNT.
Create a Dynamic Action on Click of the Check Box column using your handy-dandy, newly assigned class.
Identification Name: maintainClickedTotal When Event: Click Selection Type: jQuery Selector jQuery Selector: sumCheckBox Advanced Event Scope: Dynamic Static Container (jQuery Selector): #CLICK_SUMMER_CR
Change the action to "Execute JavaScript"
Use this JavaScript:
let isChecked = $(this.triggeringElement).prop('checked'); let amountToAdjustBy = $(this.triggeringElement).closest('tr').find('.sumAmount').html(); if( isChecked == false ) { amountToAdjustBy = (amountToAdjustBy * -1); } let currentlySummedAmount = parseFloat($v('P01_SUMMED_AMOUNT')); let newSummedAmount = currentlySummedAmount + amountToAdjustBy; $s('P01_SUMMED_AMOUNT', newSummedAmount );
Full disclosure, I wrote this off the top of my head. It looks right but, there might be a typo or something in there. At any rate, this should give you the gist of things.
Cheers,
-Joe
-
Hi Joe,
Thanks for your response. I took your code and added it to my application, but nothing happens. I put several alerts in the JavaScript code, even one at the very top of the code, and yet none of them execute, so I don't think the dynamic action is firing.
The only thing I changed in your JavaScript was the item P01_SUMMED_AMOUNT, which was changed to P604_SUMMED_AMOUNT.
Any suggestions? Thanks so much for your assistance!
Stan
-
@bondurs ,
The most likely cause is that the class isn't set on your clicked column field. You can right click on one of them and, in the developer tools, check the class attribute. That's the only reason I can think of that it wouldn't fire.
-
Hi Joe,
I checked and re-checked and re-checked my code, but I couldn't find anything that is different in my code compared to yours.
My checkbox column has the CSS Classes populated with sumCheckBox:
My Paid Amout (table column was misspelled) has been given a CSS class of sumAmount:
My Classic Report region has a static ID of CLICK_SUMMER_CR
My page item name is P604_SUMMED_AMOUNT
And here is my Dynamic Action:
Here is the html for the checkbox column:
And that's how it looks. It never executes the Dynamic Action. Might you see why?
Thanks for your help on this!
Stan
-
Your jQuery selector (my fault!) is missing the preceding period. It should be: .sumCheckBox
The period is jQuery language for the class attribute, in the same way that # indicates the ID attribute.
I really think that's the whole issue.
-Joe
-
You're the man Joe! That was the issue. Thanks so much for your help!