Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / igGrid column template – if statement inside each block

igGrid column template – if statement inside each block

New Discussion
Paulo Ferreira
Paulo Ferreira asked on Aug 20, 2012 11:42 AM

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.

Sign In to post a reply

Replies

  • 0
    [Infragistics] Borislav Traykov
    [Infragistics] Borislav Traykov answered on Aug 20, 2012 11:42 AM

    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 

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Paulo Ferreira
Favorites
0
Replies
1
Created On
Aug 20, 2012
Last Post
13 years, 11 months ago

Suggested Discussions

Tags

No tags

Created by

Created on

Aug 20, 2012 11:42 AM

Last activity on

Aug 20, 2012 11:42 AM