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,564

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

View Entire Topic
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();

}