Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8635

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

$
0
0

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

mInput._getValueHelpIcon().setSrc("sap-icon://slim-arrow-down");

//create the menu list

//oData.FullNodes contains details abt the menu

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

mInput.addStyleClass("sapUiPopupWithPadding");

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

oModel.setData(oData);

mInput.setModel(oModel);

mInput.attachValueHelpRequest(function (oEvent) {

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

filterMenuList.open(

          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) {

parentMenu.setSubmenu(mainMenu);

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

mainMenu.addItem(menuItem);

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

oMenuItemModel.setData(item);

menuItem.setModel(oMenuItemModel);

if (item.children.length > 0) {

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

}

} return mainMenu;

}

 

Thanks, Hemapriya


Viewing all articles
Browse latest Browse all 8635

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>