Hi! I'm currently trying to initialize an igGrid with some conditional templating, but I'm having some problems when I use "if" statement inside "each" blocks.
Here's my columns variable:
var tempColumns = [ { headerText: "header1", key: "Cells", dataType: "object", template: "{{each ${Cells} }} {{if ${Cells.Nome} != ''}} ${Cells.Nome} {{else}} no name {{/if}} {{/each}}", width: 250 } ];
My source list:
var tempSourceList2 = [{ Cells : [{ ID : 1, Nome: "Nome1" }, { ID: 2, Nome: "Nome2"}] }, { Cells : [{ ID: 1, Nome: "" }, { ID: 2, Nome: "Nome3"}] } ];
But the result inside the cells on the rendered igGrid is:
if ( Nome1 != '') {result += args[0]; } else {result += args[1];} if ( Nome2 != '') {result += args[0]; } else {result += args[1];}
if ( != '') {result += args[0]; } else {result += args[1];} if ( Nome3 != '') {result += args[0]; } else {result += args[1];}
Does not the each block supports if statement?
Thank you for your attention.
Hi Paulo,I'm afraid that the grid's templating capabilities do not support the "each" statement.However, the usage you're describing can be implemented using a formatter function instead of a template.You can see a basic sample of how the formatter function is used in the official sample Column Formatter.Hope this helps,Borislav