Skip to Content

How to pass dynamic value to Combobox in XML?

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 06, 2017 at 05:41 PM
    <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
    });
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 10 at 12:23 PM

    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

    Add comment
    10|10000 characters needed characters exceeded