I am so frustrated with this. I need to put an if statement into a ClientTemplate on an MVC grid. I have this :
If I just have the button by itself in the ClientTemplate, it works fine. However if I add the if statement like above, then the grid will no longer load any data. In fact, nothing in $(document).ready will run when that if statement is present. I have tried changing the if statement to simply say "if (true)" and "if (1==1)" thinking that maybe the problem is something with my ValidERAGenerated field, but that doesn't help. I cannot get any conditional statement to work like the documentation says it should. $(document).ready simply will not run at all when that conditional is there and the grid will not load any data. It appears to just break all javascript.
columns.Bound(p => p.ValidERAGenerated)
.ClientTemplate(
"# if (ValidERAGenerated == true) { #"
+
"<button class=\"btn btn-primary btn-sm\">Get ERA <span class=\"glyphicon glyphicon-file\"></span></button>"
+
"# } #"
)
If I just have the button by itself in the ClientTemplate, it works fine. However if I add the if statement like above, then the grid will no longer load any data. In fact, nothing in $(document).ready will run when that if statement is present. I have tried changing the if statement to simply say "if (true)" and "if (1==1)" thinking that maybe the problem is something with my ValidERAGenerated field, but that doesn't help. I cannot get any conditional statement to work like the documentation says it should. $(document).ready simply will not run at all when that conditional is there and the grid will not load any data. It appears to just break all javascript.