Skip to Content
0

How to pass dynamic value to Combobox in XML?

Feb 06, 2017 at 01:33 PM

140

avatar image

Hi all,

I am using XML view for coding and I try the following code for combobox.

View. XML:

<ComboBox id="idwrkschd" width="100%" placeholder="Select"

items="{ path: '/WSR_F4Set',

sorter: { path: 'ImPfNum' },

filters : [ { path : 'ImPfNum',operator : 'EQ',value1:'4045' },

{ path : 'ImPsa',operator : 'EQ',value1:'AL02' }

] }">

<core:Item key="{WorkRule}" text="{WorkRule} {Rtext}" />

</ComboBox>

I need to pass dynamic values to 'value1' field and this need to be done in controller.

Can someone help me with this?

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

1 Answer

Best Answer
avatar image
Former Member Feb 06, 2017 at 05:41 PM
0
<ComboBox id="idwrkschd" width="100%" placeholder="Select"></ComboBox>
var _oCombo = this.getView().byId("idwrkschd");

var oItems = new sap.ui.core.ListItem({
    key:"{WorkRule}",
    text:"{WorkRule} {Rtext}"
});
// Set values of ImPfNum & ImPsa
var oFilters = [new sap.ui.model.Filter("ImPfNum", sap.ui.model.FilterOperator.Contains, ImPfNum),
    new sap.ui.model.Filter("ImPsa", sap.ui.model.FilterOperator.Contains, ImPsa)];

var oSorter = new sap.ui.model.Sorter("ImPfNum");
_oCombo.bindAggregation("items", {
    path: '/WSR_F4Set',
    template: oItems,
    sorters: oSorter,
    filters: oFilters
});
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Murali,

Thanks for your answer. It was really helpful and it is working now. Only thing is that, filter parameters need to be passed like this:

var oFilters =[newsap.ui.model.Filter("ImPfNum",sap.ui.model.FilterOperator.EQ,ImPfNum),

newsap.ui.model.Filter("ImPsa", sap.ui.model.FilterOperator.EQ, ImPsa)];

Regards,

Ramya

0
Former Member
Ramya Ramasamy

ah ok.. I was trying locally & i used "Contains" operator for my model.

0