Hi, I’m trying to display the row index inside a grid column, but I’m unable to execute a calculation based on the index like:
<td>${parseInt($i) + 1}</td>
The calculation is not executed and rendered as: ${parseInt(0) + 1}
Does the templating engine support inline calculations / functions?
If I only use the $i directive each row’s index comes out as 0, and is not incremented?
Thanks in advanced.
Christoff
Hi Christoff,
The templating engine does not do any javascript evaluation inside the template body. This was done for performance purposes and the only javascript evaluation is actually performed inside block directives for the templates.
In addition to that the $i would not work properly in the context of a grid, as the grid is a bit sophisticated in the utilization of the templates, so I would suggest against using it, as it would simply not evaluate correctly for you.
You can use the row selectors feature in order to get row numbering starting at 1 (this is part of the row selectors feature).
I hope this solution works for you!
Hi Konstantin
Thanks for the response. I did use the RowSelector feature as suggested and got the desired result. I’m am just wondering why the row number are starting from 2 when I set the rowNumberingSeed to 0. I can resolve this by setting the seed to -1.
{ name: 'RowSelectors', enableRowNumbering: true, rowNumberingSeed: 0, requireSelection: true },
When only one row is found it starts from 2 when setting the seed as 0.
Thanks in advace.