Skip to Content
0

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

Sep 25, 2017 at 07:47 AM

60

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Irfan Gokak Sep 25, 2017 at 09:29 AM
0

Hi Aditi,

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

Show 1 Share
10 |10000 characters needed characters left 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();

}

0
Sharath M G Sep 26, 2017 at 03:12 AM
0

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.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0

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

1
Former Member

Thank You!

0