Hi guys! Happy new year!
I have a small app I am creating to manage my finances, I have set up a table with incomings and a table with outgoings. I have these displayed on their own particular page. I set up checkboxes so I could select which particular item has either been received or paid. I have used variables to calculate before but I cannot think how to do this, I have atttached a screen shot of the page in question.
Hi Keith,
Happy New Year!
To handle this properly, you should store the checkbox state somewhere. Ideally, add a Boolean attribute in your entity (for example, IsPaid / IsReceived) and bind the checkbox to it. That way the status can be persisted and reused for calculations and reporting.
If, instead, the checkbox is only meant for temporary selection you should create a local list (or a local structure list) to track the selected records. On the checkbox OnChange, add or remove the current row from that list depending on whether the checkbox is checked or unchecked.
For the total, you can keep a local variable (e.g., SelectedTotal) and update it in the same OnChange logic, or recompute it by iterating over the selected list.
If the checkbox state is persisted (saved in the entity), then the total can also be calculated in the OnAfterFetch of the Aggregate by summing only the records where IsPaid / IsReceived = True.
For more in-depth help, sharing a sample OML would be helpful.
Thank you for your reply! I shall look into what you said.
I have attached the OML, currently on the the Incoming page has any information on ity, I wanted to learn the basics before I went too far as I want to have incoming money on 1 page and outgoing on another
Your initial implementation using the IsSelected calculated attribute is a solid approach.
The next step is to update the total sum in the checkbox’s OnChange event. This can be done by checking whether the checkbox is selected or not and then adjusting the total value accordingly (adding or subtracting the corresponding amount).
I attached an updated OML for reference.
Result:
As a side note, I would recommend merging the two entities into a single one, for example "Transaction", and differentiating records using a Type attribute (Incoming / Outgoing).
Thank you Thank you!
I am just going over your setup to see what I can learn, I see how you have setup the event and will try recreate it, I guess I am still just stuck as to how it totalled up the "Amount" column in the first place regardless of checkbox
Integration of the incoming/outgoing isn't really necessary at the moment this is just to gauge at any one time our family budget but as Ilearn more about it and I feel like I am able I might integrate the 2.
You will need to have a local variable that will hold the total. Then in the event you update it, either add or subtract the selected amount.