In an inGrid I need to use a template to represent some data. If a hidden column value, whose data type is a bool in my grid, is true, I show one hyperlinked image, otherwise I show another. The action on the hyperlink is invoked via an OnClick event.
Using the MVC wrapper, the template looks like this:
.Template("{{if ${IsActive} == true}} <a href='#' onclick='javascriptEventA();'><img href='ImageA.png' /></a> {{else}} <a href='#' onclick='javascriptEventB();'><img href='ImageB.png' /></a> {{/if}}
Because both of my conditions contain a hash (#), the templating engine is treating all of the text between the two as comments and is stripping that information out of my template. If I remove one of the hashes, then it works fine. If i remove both, it works fine. But if I remove them, then the image won't appear to be clickable. It seems like the templating engine should be flip the sequence of when it checks for conditions vs when it checks for comments.
Unfortunately your documentation lacks any details of escaping a hash from within a template.
I perform ajax calls in the javascript events. It is important that the page doesn't refresh or navigate elsewhere.
Hello Daniel,
Thank you for using our forums.
I tried to reproduce the issue with the latest SR but with no avail.
I tried both using MVC wrapper
@(Html.Infragistics().Grid(Model).Columns(column => { column.For(x => x.ProjectId).DataType("number").HeaderText("Project Id"); column.For(x => x.Name).HeaderText("Name") .Template("{{if ${IsPostponed} == true}} <a href='#' onclick='javascriptEventA();'><img src='ImageA.png'/></a>{{else}} <a href='#' onclick='javascriptEventB();'><img src='ImageB.png'/></a> {{/if}}"); column.For(x => x.StartDate).DataType("date").HeaderText("Start Date"); column.For(x => x.IsPostponed).DataType("bool").HeaderText("Is Postponed"); column.For(x => x.EndDate).DataType("date").HeaderText("End Date"); }) .ID("grid1").Height("500px").Width("1000px")…
{
column.For(x => x.ProjectId).DataType("number").HeaderText("Project Id");
column.For(x => x.Name).HeaderText("Name")
.Template("{{if ${IsPostponed} == true}} <a href='#' onclick='javascriptEventA();'><img src='ImageA.png'/></a>{{else}} <a href='#' onclick='javascriptEventB();'><img src='ImageB.png'/></a> {{/if}}");
column.For(x => x.StartDate).DataType("date").HeaderText("Start Date");
column.For(x => x.IsPostponed).DataType("bool").HeaderText("Is Postponed");
column.For(x => x.EndDate).DataType("date").HeaderText("End Date");
})
.ID("grid1").Height("500px").Width("1000px")…
and the client only igGrid ( in the sample attached)
Which build number do you use?
I recommend you installing the latest service release (12.1.20121.2059)
There was a development issue (117672) regarding this which was fixed in the SR.
Hope hearing from you.
At the moment we are referencing CDN version:
/20121/2049/js/
Thank you for the information.
I checked the development issue (117672) and it was reported between the both service releases (12.1.20121.2049 and 12.1.20121.2059)
The fix is included in the latest one.
You should refere /20121/2059/js/.
Let me know if you need further assistance.
That solved it. I also found a workaround that also worked:
<a href='#' {{if}} {{else}} {{/if}}>
I put the condition after the href attribute. This way I only had to define one.
thanks!