Table: How to save the clicked row data into a variable for later binding

  • Roman Moraru
        Has successfully completed the online course Basics (100)
      2 years ago #34235

      Hello,

       

      Let*s say i do have  a table with two columns, name + description x 4 rows of information.

      How do i save the clicked row into a variable so it can later on be used as a binding for some controls?

      Attempt: Create a struct with two parameters name, description => create a global variable (data), with this struct as a data type => via UI Actions save the selectedItem to the data variable => bind the data variable to the controls.

      Issues: the selectedItem doesn’t get saved to the data variable; when binding the data to the controls it can’t be specified what parameter i want to use.

       

       

       

      Vitali Kurdasov
          Has successfully completed the online course Intermediate (200)
          Has successfully completed the online course Basics (100)
          Has successfully completed the online course Advanced (310)
          Has successfully completed the Intermediate Certification
        2 years ago #34237
        Up
        1
        Down
        ::

        Hi Roman,

        you can use the client-side BusinessObject SF_Ui5BindingHelper with the function getSelectedListItem to extract your clicked tablerow. In the output mapping you can map the selectedItem to your global variable.

        Please note to use the Table itemPress event instead of the ColumnListItem press event.

        Armin Winkler
            Has successfully completed the online course Introduction
            Has successfully completed the online course Intermediate (200)
            Has successfully completed the online course Advanced (300)
            Has successfully completed the online course Basics (100)
          2 years ago #34254
          Up
          1
          Down
          ::

          Hi Roman,

           

          are you using the itemPress event of the table or another widget event to which you subscribe in your process designer story?

           

          Kind regards,

          Armin

          Armin Winkler
              Has successfully completed the online course Introduction
              Has successfully completed the online course Intermediate (200)
              Has successfully completed the online course Advanced (300)
              Has successfully completed the online course Basics (100)
            1 year ago #34330
            Up
            1
            Down
            ::

            Hi Roman,

             

            you could have made it work using the ColumnListItem’s press event as well. In that case you needed to use the function getSelectedSourceItem of the business object SF_Ui5BindingHelper instead as the press event does not provide any parameter called ‘listItem’ while the itemPress event of the Table does. Please compare the description of the two events on the API Reference of OpenUI5:

             

            https://sapui5.hana.ondemand.com/1.71.47/#/api/sap.m.ListItemBase/events/press vs. https://sapui5.hana.ondemand.com/1.71.47/#/api/sap.m.ListBase/events/itemPress

             

            Concerning your question: You don’t necessarily have to use a struct with the fields if you rely purely on scripting. However, if you want to use the data source for binding your data to the UI and also want to do field mappings later on you are required to use a proper data type (i.e. struct), yes.

             

            Kind regards,

            Armin

            Roman Moraru
                Has successfully completed the online course Basics (100)
              2 years ago #34252
              Up
              0
              Down
              ::

              Hi Vitali,

               

              Thank You for your answer!

              I got a strange error: “Error: Event has no List Item” eventho there are list items ?!

              The binding to the specific property is now possible tho.

              Roman Moraru
                  Has successfully completed the online course Basics (100)
                2 years ago #34270
                Up
                0
                Down
                ::

                Fixed: via itemPress it works, ColumnListItem press doesn’t for some reason.

                 

                Another question: for such purposes it is always required to use a struct with the properties ?

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

              You must be logged in to reply to this topic.