else if condition in js render template

4.6k views Asked by At

Hi i have use the following code snippet in js render template.

{{if Expanded}}e-gridtreerowexpand {{else (!Expanded)&&(HasChildGridRecords)}} e-gridtreerowcollapse {{/if}}

In this else condition did not work. Where Expanded, HasChildGridRecords are the properties present in the data object to be rendered.

How to resolve this propblem.

1

There are 1 answers

2
BorisMoore On

That should work. (Though it is redundant to put (!Expanded) since you already tested that in the if).

You can write

{{if Expanded}}
  e-gridtreerowexpand
{{else HasChildGridRecords}}
  e-gridtreerowcollapse
{{/if}}

(No need for the parens either)

If Expanded is true you get the first block rendered.

If HasChildGridRecords truey, and Expanded is falsey, you get the second block.