Grid column conditional ClientTemplate breaks grid

3 posts, 0 answers
  1. Daniel
    Daniel avatar
    3 posts
    Member since:
    Sep 2014

    Posted 23 Mar 2015 Link to this post

    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)
            "# 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. Daniel
    Daniel avatar
    3 posts
    Member since:
    Sep 2014

    Posted 23 Mar 2015 in reply to Daniel Link to this post

    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.
  3. Dimiter Madjarov
    Dimiter Madjarov avatar
    2123 posts

    Posted 25 Mar 2015 Link to this post

    Hello Daniel,

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

    Dimiter Madjarov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top