Skip to Content
0

Expression Binding for number property of ObjectListItem

Feb 10, 2017 at 04:19 PM

65

avatar image

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.

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

4 Answers

Srikanth KV Feb 10, 2017 at 05:51 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Veeraraghavan Narasimhan
Feb 11, 2017 at 12:45 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Akhilesh Upadhyay Feb 13, 2017 at 01:13 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Adam Harkus Mar 08, 2017 at 04:02 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded