Skip to Content
author's profile photo Former Member
Former Member

How to display the selected menu text name in the input control ?

Hi All,

When the valueHelprequest event is fired for the Sap.m.Input , I am popping up the Menu list. When the Menu Item is selected , I want to set the text to the input.

P.s It is a dynamic control.

Can someone help me on this.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2015 at 06:32 AM

    Hi All,

    Please find the code below code , for setting the selected menu text name in the input control.

    //create the input control

    var mInput = new sap.m.Input({ showValueHelp: true, showSuggestion: true, valueHelpOnly: true, placeholder: "Choose value", });

    //change helpicon of the input control


    //create the menu list

    //oData.FullNodes contains details abt the menu

    var filterMenuList = this.constructFilterMenu(oData.fullNodes, null, mInput,oData.dimensionId);


    var oModel = new sap.ui.model.json.JSONModel();



    mInput.attachValueHelpRequest(function (oEvent) {

    var eDock = sap.ui.core.Popup.Dock;

    true /*First item already highlighted*/,

    mInput.getFocusDomRef()/*Dom reference which gets the focus back when the menu is closed*/,

    eDock.BeginTop, /*"Edge" of the menu (see sap.ui.core.Popup)*/

    eDock.BeginBottom, /*"Edge" of the related opener position (see sap.ui.core.Popup)*/

    mInput.getDomRef() /*Related opener position (see sap.ui.core.Popup)*/


    }, this);

    constructFilterMenu: function (data, parentMenu, oLabel,dimensionId)

    { var that = this;

    var mainMenu = new sap.ui.unified.Menu();

    var parentLabel = oLabel;

    if (parentMenu!= null) {


    } else {

    var oModel = new sap.ui.model.json.JSONModel();

    oModel.setData(data); mainMenu.setModel(oModel);

    mainMenu.attachItemSelect(function (oMenuSelect)

    { var s = parentLabel;

    if (oMenuSelect.getParameter("item").getMetadata().getName() == "sap.ui.unified.MenuItem") {

    parentLabel.setValue(oMenuSelect.getParameter("item").getText()); }



    for (var key = 0, l = data.length; key < l; key++)


    var item = data[key];

    var menuItem = new sap.ui.unified.MenuItem({tooltip: item.caption, text: item.caption});


    var oMenuItemModel = new sap.ui.model.json.JSONModel();



    if (item.children.length > 0) {

    this.constructFilterMenu(item.children, menuItem, oLabel,dimensionId);


    } return mainMenu;


    Thanks, Hemapriya

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2015 at 09:07 AM

    What have you tried yourself so far?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.