Skip to Content
avatar image
Former Member

How can we get multiple Dialog boxes using the same function?

Hi,

I have a table fetching oData and various input fields to apply filters.

On clicking F4 when the input field is active, a pop up with a list of filter values form oData service should appear. Now I wanted to use the same function for calling different dialogs, each through its respective input field using switch statement.Is this possible? If yes, how?

Thank You

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 25, 2017 at 09:29 AM

    Hi Aditi,

    It is possible. Please explain more so that i can give u possible solution.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Irfan,

      I have say 2 input fields each having multiple selection available.On pressing F4 when active, a pop up appears with respective filter values out of which more than one selection is possible, which on clicking on "Ok" would be applied to the table.Now to reduce redundant code, I wish to use the same function and call dialogs for the respective input field using the id of the input field.I tried the following code.But its giving the error : "Uncaught TypeError: Cannot read property 'open' of undefined"

      _getDialog : function (inputId)

      {

      if (!this._valueHelpDialog)

      {

      switch (inputId)

      {

      case "MaterialID":

      this._valueHelpDialog = sap.ui.xmlfragment("mpo.fragment.Dialog",this);

      break;

      case "MRPController":

      this._valueHelpDialog = sap.ui.xmlfragment("mpo.fragment.DialogMRPCtlr",this);

      break;

      }

      this.getView().addDependent(this._valueHelpDialog);

      }

      return this._valueHelpDialog;

      },

      handleValueHelp : function (oEvent)

      {

      var inputId = oEvent.getSource().getId();

      this._getDialog(inputId).open();

      },

      _handleValueHelpSearch : function (evt) {

      var sValue = evt.getParameter("value");

      var oFilter1 = new sap.ui.model.Filter("MaterialID","EQ", sValue); evt.getSource().getBinding("items").filter([oFilter1]);

      },

      _handleValueHelpClose : function (evt) {

      var oSelectedItem = evt.getParameter("selectedItem");

      if (oSelectedItem) { var FilteredItems =oSelectedItem.getTitle();

      var bindItems = this.byId("table").getBindingInfo("items"),

      template = bindItems.template,

      path = bindItems.path;

      var filterMaterialID = new sap.ui.model.Filter("MaterialID", "EQ", FilteredItems);

      }

      this.getView().byId("table").bindItems(path, template, null, [filterMaterialID]);

      },

      onCloseDialog :function(){

      this._getDialog().close();

      }

  • Sep 26, 2017 at 03:12 AM

    As I understand, one function which handles value help for two fields.

    Use the Event paramaters and attach some custom parameters to the event handler methods to differentiate the source of the call.

    Add comment
    10|10000 characters needed characters exceeded