cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

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

Former Member
0 Likes
1,559

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Sharathmg
Active Contributor
0 Likes

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.

Former Member
0 Likes

Hi Sharath,

I have tried that but am getting errors.The snippet I used is as following :

https://answers.sap.com/comments/316211/view.html

Its giving an error for passing inputID.

Thank You

Sharathmg
Active Contributor

When using a control by passing the input id, as a practice get the control into a separate variable and then perform the bind items or any further action on it.

Paste the code and line at which the error is raised.

Regards,

Sharath

Former Member
0 Likes

Thank You!

irfan_gokak
Contributor
0 Likes

Hi Aditi,

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

Former Member
0 Likes

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();

}