cancel
Showing results for 
Search instead for 
Did you mean: 

Expression Binding for number property of ObjectListItem

former_member239819
Participant
0 Kudos

Is there a way to set up expression binding on the number property of an Object ListItem?

Here's what it's doing now...

<ObjectListItem
     number="{ path: 'basket>TotalPrice', formatter: '.formatPrice'}"                                              
>

What I need to do is set path depending on the whether {site>/ShowPrices} is true or false..

Is that possiible.

 <ObjectListItem
     number="{ path: = ${site>/ShowPrices} ? 'basket>TotalPrice' : '0', formatter: '.formatPrice'}"                                              
>

E.g show the price if site>/ShowPrices is true, else show 0.

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member227918
Active Contributor

in this case its not possible, and as Veera suggested, pass both value in parts and handle and put condition in formatter function as below:

<ObjectListItem number="{ parts : [{path: 'basket>TotalPrice'},{ path : 'site>/ShowPrices'}], formatter: '.formatPrice'}">

and formatter:

formatPrice: function(totalValue, bShowPriceValue){
  var formattedValue = 0;
  if(bShowPriceValue){
   formattedValue = totalValue;
  }
  return formattedValue;
}

Hope this help.

-Akhilesh

former_member228602
Contributor

You cannot use expression binding to assign a binding . You can either apply complex binding of parts

<ObjectListItem number="{ parts : [{path: 'basket>TotalPrice'},{ path : 'site>/ShowPrices'}], formatter: '.formatPrice'}">

or

<ObjectListItem number="{= ${site>/ShowPrices} ? ${basket>TotalPrice} : '0'  }">

Thanks and Regards,
Veera

former_member239819
Participant
0 Kudos

Thank you. I've need to set the value to 0 in the controller instead.

former_member365727
Active Contributor
0 Kudos

Expression binding can set a pre-defined constant values after evaluating the expression. In your case after the expression is evaluated you are setting a model value instead of a constant.

Possible approach would be formatter only like you did