cancel
Showing results for 
Search instead for 
Did you mean: 

How to bind select control to two different path based on a condition?

0 Kudos

Hi,
I am trying to bind the slect control to two different paths in sapui5 application.
Here is my code:
<Select id="QuotePartnerSelect" forceSelection="false" change="onSelectRole" items="{= ${/PROCESS_TYPE} === 'ZK01' ? ${path:'HarmonyConfig>/PLACEHOLDERS/QuotationCloudPartner/PARVW'} : ${path:'HarmonyConfig>/PLACEHOLDERS/QuotationERPPartner/ERP_PARVW'} }" selectedKey="{path:'ROLE'}"> <core:Item key="{path: 'HarmonyConfig>KEY'}" text="{parts : [{path: 'HarmonyConfig>VALUE'}, {path: 'HarmonyConfig>FIELD_NAME'}], formatter: '.formatter.selectDeafultText' }"/> </Select>

I looked in the developer guide for complex experession binding but i I get the error of w.push is not a function. any help would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

I don't think you can do that with expression binding

the combobox is used in table, i want to bind it dynamically, i put a formatter in tooltip to manipulate the item binding

<comm:ComboBox tooltip="{path:'ViewModel>ATTNAME',formatter:'com.****util.Util.getItems'}" > </comm:ComboBox>

Answers (2)

Answers (2)

former_member227918
Active Contributor
0 Kudos
,

I think conditional path you cannot set using expression binding.

you can try this from controller file inside routeMatched or bindingChange function of view, as

if(oModel.getProperty('/PROCESS_TYPE') == 'ZK01')

sPath = 'HarmonyConfig>/PLACEHOLDERS/QuotationCloudPartner/PARVW'

else

sPath = 'HarmonyConfig>/PLACEHOLDERS/QuotationERPPartner/ERP_PARVW'

and then

oSelect.bindItem(sPath,oTemplate) //oTemplate = this.byId(id of core:Item of select control).clone()

hope this helps.

Regards,

Akhilesh

srinivas_sistu
Active Contributor
0 Kudos

Hi,

in the error you are getting, What is w in w.push? I mean, have you defined any object with name "w"?do you have any code, which does a Push,in your controllers?

Regards,

Srinivas

0 Kudos

I think the error is due to some problem in the binding of items in select control. I am using the same syntax for text controlaand maybe there is a different way to bind items based on condition. I was thinking if someone could correct my syntax for binding in select control. I will try to debug from where this w.push is coming. The issue is these xml views getloaded initially so error comes form data.js files and it is difficult to understand. I will try to find out form where is this w.push getting called.