cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass dynamic value to Combobox in XML?

former_member195820
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
<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
});
former_member195820
Participant
0 Kudos

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

Former Member
0 Kudos

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

minjie_lao
Product and Topic Expert
Product and Topic Expert
0 Kudos

it's working for me, thanks!

Answers (1)

Answers (1)

raina_goyal
Participant
0 Kudos

Hi Murali,

It is not working for me. It is giving ImPfNum as undefined error and if I Pass the value then it is not dynamic.

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

Please help.

Thanks,

Best Regards,

Raina