Continue from Part 2…
In the previous Chapter, I had shared on the basic coding for SAVE New data.
In this Final Chapter, let's concentrate on how can we UPDATE a single record using
- UpdateIf function based on CONDITION
Why use Toggle?
As I was responding to @OlaH’s question, and understand that using Toggle looks more gorgeous and App’s like looking, I also found that Toggle is very suitable for small screen, user-friendly and widely used in most of the Apps.
Anyhow, as Toggle hasmany behavior action, this shall be selected carefully:
- OnCheck
- OnUnCheck
- OnChnage
- OnSelect
The main reason that I use OnSelect is because I wish to have the UpdateIf being triggered only when selected, NOT OnCheck or OnUnCheck.
[OnChange must be avoided here because when I change the Date, the defaults values will make the Toggle value change to either true / false (defaults value), and this will trigger UpdateIf, In which this is supposed not to happen.]
Formula
Toggle1.OnSelect =
UpdateContext({LoadingIcon: true});
UpdateIf(TableAttendance,
Date = 'Today-Date'.Text && Grade = DropdownGrade.Selected.Result && StudentName = 'Student-Name'.Text && Attendance <> Text(Toggle1.Value),
{Attendance: Toggle1.Value, Reason: DropdownReason.Selected.Value, Teacher: DropdownTeacher.Selected.Result}); UpdateContext({LoadingIcon: false})
Rational Reason
What happens when toggle is SELECTED (or changed, and after RELEASE of the toggle button):
Lastly
Patch, ForAll, UpdteIf, with conditions formula, altogether are sufficient in creating a CRUD environment.
[I do not include DELETE in this sample as it is not my intention to delete data]
Appreciate comments for improvement and at the same time, wishing those who needs equivalent application will benefit from this detailed explanation sample.
Feel free to see the:
- Sample Apps
- Sample Data
- Simple demo video
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.