Forum

Jennifer Häfner
Moderator
    Has successfully completed the online course Intermediate (200)
    Has successfully completed the online course Advanced (300)
    Has successfully completed the online course Basics (100)
    Has successfully completed the online course Advanced (310)
    Has successfully completed the online course Advanced (320)
    Has successfully completed the Intermediate Certification
    Has successfully completed the Advanced Certification
4 years, 11 months ago #24015
Up
2
Down
::

Hi Timo,

In OpenUI5, you can uncheck a CheckBox like this:
var oCheckbox = sap.ui.getCore().byId("Screen1--checkbox"); //insert the screen name and the id of your checkbox
oCheckbox.setSelected(false);

If all CheckBoxes that you want to uncheck are wrapped in a container, e.g. Grid or FlexBox, you can first retrieve all CheckBoxes in the container, then uncheck them in a loop:
var oContainer = sap.ui.getCore().byId("Screen1--grid"); //insert your container's id here
var aContainerContent = oContainer.getContent(); //get all controls in the container. if you use a FlexBox, you can retrieve the items by using 'oContainer.getItems()'
aContainerContent.forEach(function(oControl){
if (oControl.getSelected){ //check if the current control has the method 'getSelected'. You don't have to do this if you only have CheckBoxes in your container
oControl.setSelected(false);
}
});

If your CheckBoxes are all on the same page, you can also use this method:
$('#Checkboxes--CheckboxesPage .sapMCb').each(function(){ //insert your page's id in the selector. 'sapMCb' is the UI5 class for CheckBoxes
var oCheckBox = sap.ui.getCore().byId(this.id); //get UI5 object
if (typeof oCheckBox !== 'undefined'){
oCheckBox.setSelected(false);
}
});

I hope this helps!