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

How to load table Key/Value pair directly in Combobox using oDataModel in SAPUI5 (JS-View/Controller)

I have many combo boxes in my form and i want to load the values of all the comboboxes in onInit function of my controller.

For Now, I have following queries kindly guide me as i am totally new one in this technology.

1. How to refer any view object in the controller or do need to refer it to fill data in any specific control of view or it can be done within the view?

2. How to papulate data in combobox using oDataModel and how to react and refetch data on the basis of selected combobox value from a web service?

3. Is there any way to use Function Keys and Enter Key with in the form?

4. Is there any way to transfer control on Enter Key to any specific Field?

Regards

M.S. Arain

ComboQuestion.png (17.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Dec 08, 2014 at 10:16 PM

    Hi,

    what i did was build a generic webservice that supports key and value pairs based on a type. So you can use the same service for multiple f4 helps. Which then has a db table in the backend where you fill in the values. You can also just do one service per combobox if you want to.

    So basically the service returns multiple entities with a key and a value. what you do then is to bind your control s items against that service.

    Something like this:

    <Select id="VehSearchStateInput" items="{ path: '/GenericKeyValueSet'

    }" width="100%">

    <core:Item id="VehSearchStateInputItems" key="{KeyV}" text="{Value}" />

    <layoutData>

    <l:GridData span="L9 M9 S12" />

    </layoutData>

    </Select>

    Then in your controller you can define a filter if need be that is called when the control is loaded:

    var oVehState = sap.ui.getCore().byId('VehSearchStateInput');

    var vState = "STATE";

    var oFilter1 = new sap.ui.model.Filter("Type", sap.ui.model.FilterOperator.EQ, vState);

    oVehState.mBindingInfos.items.binding.filter(oFilter1);

    Then when you add the attribute change : with a function handler to your select control you can define a event that is executed when something is selected.

    You can get which item is currently selected via

    var vState = sap.ui.getCore().byId('VehSearchStateInput').getSelectedKey();

    which you then can put somewhere in your model.

    hope this helps a bit.

    cheers

    Kay

    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.