Dortimer
Dortimer

Reputation: 617

Kendo UI Grid get Row Id in ClientTemplate

I have a custom template for a column in a KendoUI Grid, and I need to get the Id of the row so I can pass it to a Javascript function. I should note that in the ClientTemplate I have some Url.Actions that can access the Id with "#=Id#" but that doesn't work with the function call for some reason.

"#if (hasLogFile(#Id#)) {#" +
    "<a role='button' class='btn btnAwesome' href='" + Url.Action("GetLogFile", "Run") + "/#=Id#' title='Log File'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>" +
"#} else {#" +
    "<a role='button' class='btn btnAwesome disabled-icon' title='Log File'><i class='fa fa-file-text-o' aria-hidden='true'></i></a>" +
"#}#"

I have tried a myriad of things for the parameter to hasLogFile(); (including #=Id#). It is possible to get some things passed into the function such as various jQuery objects or plain text. It's just a matter of getting the Id.

Upvotes: 1

Views: 1178

Answers (1)

Ross Bush
Ross Bush

Reputation: 15155

The template data is wrapped in a way that you can reference it directly in your template code logic.

#if (hasLogFile(#Id#))…

becomes

#if (hasLogFile(Id))…

Upvotes: 1

Related Questions