sap.m.tableselectdialog – get selected value

  • Philipp
        2 years ago #33486

        Hello all,

        I am currently trying to use the sap.m.tableselectdialog widget to help the user with input.

        Unfortunately I fail to get the return value (selected row).

        In the UI5 doc, it should be this:

         

        
        handleClose: function(oEvent) {
        
        // reset the filter
        var oBinding = oEvent.getSource().getBinding("items");
        oBinding.filter([]);
        
        var aContexts = oEvent.getParameter("selectedContexts");
        if (aContexts && aContexts.length) {
        MessageToast.show("You have chosen " + aContexts.map(function(oContext) { return oContext.getObject().Name; }).join(", ")); }}
        
        

        sap.m.table on openui5.hana

         

         

        I respond to the confirm event. My most promising attempt was the methods ITIZ_Utilities.getSelected[..].

        However, I come across the error
        “Type error: cannot read the properties of undefined (reading getObject)”.

        The problem should be similar to selecting table rows e.g. in sap.m.Table.

         

        Thank you

        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
          2 years ago #33578
          Up
          1
          Down
          ::

          Hi Philipp,

          to extract the selected item in the TableSelectDialog after the event ‘confirm’, you need the following UI5 syntax:
          oEvent.getParameter("selectedItem").getBindingContext(<bindingContext>).getObject();
           

          The binding context depends on how you map your data to your table. If you store the data in a global variable first and then map this global variable to the table, the binding context is ‘variableHolder’.

          If you map the data using data source, the binding context is the respective screen name where the dialog is placed in the UI Designer. In this case, you can simply use the Client-Side Business Object function ‘ITIZ_Utilities – getSelectedItem’, which will return the selected item object.

          Just let me know if you have any further questions.

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

        You must be logged in to reply to this topic.