Skip to Content
0

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

Nov 01, 2016 at 03:59 PM

98

avatar image

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.

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

3 Answers

srinivas sistu Nov 01, 2016 at 04:19 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Akhilesh Upadhyay Nov 01, 2016 at 06:51 PM
0
,

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

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Nov 02, 2016 at 02:17 PM
0

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>

Share
10 |10000 characters needed characters left characters exceeded