cancel
Showing results for 
Search instead for 
Did you mean: 

How to uncheck a checkbox from a dialog box and remove from view

former_member192494
Participant
0 Kudos

Hi All,

I have button where on click opens a dialog box which has 5 check boxes with text for each check box [generating dynamically using row repeater].

If one or all of the check box is checked, the check box with its text should get displayed in the view on closing the dialog box. I am able to display this, that is the checked ones.

But, after closing the dialog box if the user wants to unselect a check box that is not required for the next time, the check box that is unchecked should get removed from the view.  How is this possible ?

Thanks,

Ravikiran

Accepted Solutions (0)

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

Can you share your code, especially the data binding for the checkboxes in both the dialog as well as the view

former_member192494
Participant
0 Kudos

Hi Robin,

Pleas find the below code,

var oDialogScope = new sap.ui.commons.Dialog({

  width : "20%"

  });

  oDialogScope.setTitle("Add Scope of Work");

  var oScopeButton = new sap.ui.commons.Button({

  text : "OK",

  });

  var oRowRep = new sap.ui.commons.RowRepeater();

  var oChkBox = new sap.ui.commons.CheckBox({

  text : "{EventDropDown>label}",

  checked : "{EventDropDown>checked}",

  change : function(oEvent) {

  var l1 = new sap.ui.commons.CheckBox({

  editable : false

  });

  l1.setChecked(this.getChecked());

  l1.setText(this.getText());

  oScopeButton.attachPress(function() {

  var cellM = new sap.ui.commons.layout.MatrixLayoutCell();

  cellM.addContent(l1);

  var oScopeRow = sap.ui.getCore().byId("SR1");

  oScopeRow.addCell(cellM);

  oDialogScope.close();

  return;

  });

  }

  });

  oRowRep.bindRows("EventDropDown>/checked", oChkBox);

  oDialogScope.addContent(oRowRep);

  oDialogScope.addContent(oScopeButton);

  oDialogScope.addStyleClass("DialogCss");

  oDialogScope.open();

Regards,

Ravikiran

former_member192494
Participant
0 Kudos

Hi Robin,

I have a button in view, on click of the button the above action takes place.

Thanks,

Ravikiran

Qualiture
Active Contributor
0 Kudos

Looking at your code, it seems it already creates the views checkboxes in the checkbox checked event, which seems incorrect (should only happen when you click the OK button I guess?)

in your case, simplest would be to first remove everything in the cell, and then re-build the cell with the selected checkboxes