This is a migrated thread and some comments may be shown as answers.

Grid column conditional ClientTemplate breaks grid

2 Answers 194 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 23 Mar 2015, 03:01 PM
I am so frustrated with this. I need to put an if statement into a ClientTemplate on an MVC grid. I have this :

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.

2 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 23 Mar 2015, 03:39 PM
I finally figured it out. It was because I had another column that had a dollar sign in the format.

columns.Bound(p => p.CheckAmount).Title("Check Amt.").Format("${0:n2}").Width(100);

That is how I had been formatting the money. When I removed that dollar sign then everything ran successfully. I changed the format to say Format("{0:c2}") and now it is showing a dollar sign and working correctly.
0
Dimiter Madjarov
Telerik team
answered on 25 Mar 2015, 07:52 AM

Hello Daniel,

Thanks for the update. I am glad the issue is resolved. Do not hesitate to contact us again if additional problems arise.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or