Reset a screen

Tagged:
  • Vasileios Thanasias
        Has successfully completed the online course Basics (100)
      1 year ago #35375

      Hello, is there any way (event) to reset a screen. I have some checkboxes checked, but when I want to return to the screen, I would like to have all the checkboxes unchecked, as in the begining.

      Jennifer Häfner
          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
        1 year ago #35411
        Up
        1
        Down
        ::

        Another way to reset screens is to implement them as modules and then loading these modules in your app. When unloading the module and then loading it again, all elements will be re-initialized and therefore reset.

        You can find more about modules here:

        Jennifer Häfner
            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
          1 year ago #35409
          Up
          0
          Down
          ::

          Hi Vasileios,

          There is no built-in function that resets all elements on a screen, but you can implement it the following way:

          Subscribe to the ‘onBeforeShow’ event of the screen you want to reset. After the event, execute this code (adapt it to your use case):

          var aCheckboxes = $("#ScreenID").find(".sapMCb"); // get all checkboxes on the screen
          
          for (var i = 0; i < aCheckboxes.length; i++) {
          var sId = aCheckboxes[i].id; // get the ID of the element
          sap.ui.getCore().byId(sId).setSelected(false); // reset the checkbox
          }
          Vasileios Thanasias
              Has successfully completed the online course Basics (100)
            1 year ago #35412
            Up
            0
            Down
            ::

            ok thank you very much!

            The first suggestion worked perfectly!

          Viewing 4 posts - 1 through 4 (of 4 total)

          You must be logged in to reply to this topic.