Skip to Content
avatar image
Former Member

Sap ui5 check box selection

I have generated 12 check boxes for each month in the year through code in the controller. I also have a recal button on the same view which on press I want to determine the check boxes selected to make an Odata call and pass the selection. My code this.byId("chkbox1").getSelected() is not working inside the press event of the recal button.

Please help me what am I doing wrong??

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jul 19, 2017 at 09:57 AM

    better do in shortway,

    create a model with 12 parameters, and bind to checkboxes. Whenever they are checked, values will be updated, you can just check the model itself.

    var oModel = new sap.ui.model.json.JSONModel({
    jan:"",feb:"",.....december:"" }); this.getView().setModel(oModel,"CHKLIST");
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 19, 2017 at 07:53 AM

    First, when you are generating the check box, assign a unique ID to each checkbox.

    Assign an event handler for the checkbox - "select" event. In the event handler, store the id/index of the checkbox in an array.

    Have one event handler for all check boxes.

    Now, as and when the user clicks on the checkbox, the event handler gets triggered and the id or any other details of the clicked checkbox can be maintained in the array.

    Note: Array should be declared outside the event handler. Use debugger console to verify the process.



    Add comment
    10|10000 characters needed characters exceeded