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

Kendo MVC Grid with conditional area in ClientRowTemplate

1 Answer 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ewald
Top achievements
Rank 1
Ewald asked on 28 Nov 2012, 04:09 PM
Hi,

I am using the Kendo Grid with the MVC helpers, and want to make a conditional area in ClientRowTemplate.
Currently I have the following ClientRowTemplate:
.ClientRowTemplate("<tr>" +
                       "<td >" + 
                           "${ FirstName} " +
                       "</td>" +
                       "<td> " +
                           "${ LastName} " +
                       " </td>" +
                   "</tr>" +
                   "${optionalNotes(Notes)}")
and this JavaScript:    
function optionalNotes(t) {
    if (t.length > 0) {
        return "<tr><td colspan='2'>" + t + "</td></tr>";
    } else {
        return "";
    }
}
This works partially. My JavaScript is being fired, but the result is escaped before it is being added into the grid. So, instead of getting an optional tablerow with Notes, I get the html displayed.
Is there any way to indicate to Kendo to treat the JavaScript output as raw HTML in this context?
Thanks,
Ewald

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 30 Nov 2012, 09:28 AM
Hello Ewald,

As my colleague already replied you in the support ticket you opened, you should use the other expression syntax #= # which does not encode the result.

.ClientRowTemplate("<tr>" +
                       "<td >" +
                           "${ FirstName} " +
                       "</td>" +
                       "<td> " +
                           "${ LastName} " +
                       " </td>" +
                   "</tr>" +
                   "#=optionalNotes(Notes)#")


Regards,
Petur Subev
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
Ewald
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or