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

Error when using logic in ClientRowTemplate

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 07 Dec 2012, 08:26 PM
I meant ClientTemplate. It won't let me edit the title of this post.

        columns.Bound(t => t.IsOpen)
        .Title("Status")
        .ClientTemplate(
            "# if (#=IsOpen# == 'True') { #" +
            "something" +
            "# } else { #" +
            "something else" +
            "# } #"
        );

Uncaught Error: Invalid template:'<tr data-uid="#=uid#"><td ># if (#=IsOpen# == 'True') { #something# } else { #something else# } #</td></tr>' Generated code:'var o,e=kendo.htmlEncode;with(data){o='<tr data-uid="'+(uid)+'"><td >'; if (;o+='=IsOpen'; == 'True') { ;o+='something'; } else { ;o+='something else'; } ;o+='</td></tr>';}return o;'

        

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 10 Dec 2012, 02:50 PM
Hello Phil,

 Change your template to:

.ClientTemplate(
            "# if (IsOpen == 'True') { #" +
            "something" +
            "# } else { #" +
            "something else" +
            "# } #"
        );


You should not nest #= # blocks inside # #. Also if IsOpen is boolean use true instead of 'True':

.ClientTemplate(
            "# if (IsOpen == true) { #" +
            "something" +
            "# } else { #" +
            "something else" +
            "# } #"
        );

Greetings,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or