cancel
Showing results for 
Search instead for 
Did you mean: 

Filter MultiInput suggestionItems by value from different control

former_member213564
Participant
0 Kudos

Hi experts,

I have a MultiInput bind to a OData Model which shows suggestion. Can I filter those suggestions by a value of another control?

Here for an example I have two datePickers and MultiInput and I would like to filter the suggestion list by the values from datePickers


<Label text="Date range filter"  labelFor="filterDateRangeSelection"/>

  <l:HorizontalLayout class="sapUiContentPadding" width="100%" id="filterDateRangeSelection">

  <l:content>

  <DatePicker

  id="filterDateFrom"

  displayFormat="short"

  class="sapUiSmallPaddingBegin"

  change="onChangeFilterDateFrom"

  />

  <DatePicker

  id="filterDateTo"

  displayFormat="short"

  change="onChangeFilterDateTo"

  class="sapUiSmallMarginBegin sapUiSmallPaddingEnd"

  />

  </l:content>

  </l:HorizontalLayout>

  <Label text="Names" labelFor="filterPlanNames"/>

  <MultiInput id="filterPlanNames"

  suggestionItems="{

                         path: 'plan>/PlansSet',

                         sorter: { path: 'plan>Name' },

  filter: VALUES-FROM-DATE-PICKER-ABOVE

                     }"

        showValueHelp="false"

        placeholder="{i18n>filter.dialog.planNames.placeHolder}"

        enableMultiLineMode="false" >

       

    <core:Item key="{plan>TestPlanIds}" text="{plan>Name}" />

     </MultiInput>

Kind regards,

Filip

Accepted Solutions (1)

Accepted Solutions (1)

jamie_cawley
Advisor
Advisor
0 Kudos

Depending on what your model supports, define a function in the controller with...

var aFilters = [];

aFilters.push(new Filter("ColName", sap.ui.model.FilterOperator.BT, from, to));

this.getView().byId("filterPlanNames").getBinding("suggestionItems").filter(aFilters);

Regards,

Jamie

SAP - Technology RIG

former_member213564
Participant
0 Kudos

Thank you Jamie, it runs like clockwork

Regards,


Filip

former_member213564
Participant
0 Kudos

one more question. Is it possible to make

this.getView().byId("filterPlanNames").getBinding("suggestionItems").filter(aFilters);


async? My UI is frozen until I get the response from the OData call

Thanks,

Fiilp

jamie_cawley
Advisor
Advisor
0 Kudos

Can you use a json model for the suggestion items?

Regards,

Jamie

SAP - Technology RIG

former_member213564
Participant
0 Kudos

I was hoping there would be an option something like

this.getView().byId("filterPlanNames").getBinding("suggestionItems").filter(aFilters, true);


to make an async call..


I'm using JSON model now but I can't get the correct binding path..can you please give me your opinion where am I wrong?


jamie_cawley
Advisor
Advisor
0 Kudos

Try setting the suggestionItems to "{suggestions>/results}"

Regards,

Jamie

SAP - Technology RIG

former_member213564
Participant
0 Kudos

I tried that as well..unfortunately it's not working..

EDIT: I had to remove "/" from <core:Item .. /> and it works now.


Thank you Jamie for your time and help

Kind regards,


Filip

jamie_cawley
Advisor
Advisor
0 Kudos

Compare you code to

SAPUI5 Explored

Regards,

Jamie

SAP - Technology RIG

former_member601749
Discoverer
0 Kudos

perfect ! worked like a charm.

Answers (0)