Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
ClausS
38
Views
6
Comments
How to see if checkbox is checked or not
Discussion
How-to
Hi - here is a newbie question.
I'm using a checkbox in a list table to be able to mark several items.
When I resort some of the columns, my selections disappear.
I understand that I need to create an OnCheckBoxChange method to capture the change in a variable.
However, when I create this method and insert an assign into it, I am not able to see the relevant variable in te checkbox widget to reveal whether it is selected or not.
In the variable browser, I see only two variables for the checkbox widget, "Valid" and "ValidationMessage".
Where can I find the variable corresponding to the selection status?
-- Claus
André Vieira
Staff
Hi Claus,
Welcome to the OutSystems Community!
I'll assume here, since you're new to this technology, that you have been going thru the
online training
, my answer will include concepts you can learn on your own with this training.
If you haven't seen the online training I strongly encourage you to do so...
The sorting functionality is performed at database level, i.e. when you sort by a column the query that retrieves data and displays it in the screen is re-executed and its results are again bound to the widget on the screen. This means that the selections you did on the checkboxes (and that were only in memory and not stored in the database) are lost.
Now, the solution really depends on what you want to do but, coming to your question, you can implement an action that is triggered when the selection of the checkbox changes, that would be the OnCheckBoxChange you mention.
Every input on the screen must be bound to a variable, it is this variable that stores the value of the user input and in the case of the checkbox this is a boolean variable. So to validate if the checkbox is selected or not you must test the variable and not the widget. In the case that the checkbox is in a TableRecords widget surely you have a boolean attribute in the query the fills this TableRecords and that is the variable bound to the checkbox. That is the variable you want to test!
Cheers
ClausS
Ok, I understand. Thanks. Yes, I have a variable that the checkbox is bound to:
DecisionModel.Selected - and it is a boolean.
I've implemented OnCheckBoxChange.
I thought I would be assigning "DecisionModel.Selected = widget.checkbox.value"
But what exactly will I have to do in the OnCheckBoxChange action to ensure that the database is updated?
André Vieira
Staff
Depends...
Can you detail more what you want to do or attach an example. If you wish to attach your eSpace module to the post you can export it from the development environments using Ctrl+S.
ClausS
I simply want to avoid that the checkbox selections are cleared when the listbox is resorted (by clicking one of the other columns). I have tied a variable "Selected" to the checkbox. It is correctly set to true or false when the checkbox is selected. However, if I resort the columns, all the checkboxes are cleared.
This doesn't seem to be the default behavior, you would want.
André Vieira
Staff
Unfortunately due to the nature of web applications that is not that easy :(
Let me try to give you some guidance, but let me warn you that this might be complex for a newbie...
First of all you need to be aware that this solution should not be used when you have a large list of elements to select from. To keep the selections you'll need to keep everything in memory and also sort the list in memory. For that you'll need to use
this component
.
Check the attached example and the reminders inside for help.
Cheers
InMemorySelection.oml
ClausS
Thanks - I will check it out!
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...