
FAYE SCHAB
Top achievements
Rank 1
FAYE SCHAB
asked on 21 Jun 2013, 02:57 PM
It seems like the only way to define templates for controls declared with .Net syntax is to use escaped literal text. Whereas if the control is declared with javascript syntax, one can embed the template content in a named/ID'ed script tag and reference that ID. Is there any way to accomlish this with .Net syntax?
4 Answers, 1 is accepted
0
Hello Faye,
Please give concrete examples (snippets) when describing the problem so we can understand what exactly you mean.
Basically the sharp symbols inside templates should be escaped because they are are used to evaluate client expressions.
http://docs.kendoui.com/getting-started/framework/templates/overview
Regards,
Petur Subev
Telerik
Please give concrete examples (snippets) when describing the problem so we can understand what exactly you mean.
Basically the sharp symbols inside templates should be escaped because they are are used to evaluate client expressions.
http://docs.kendoui.com/getting-started/framework/templates/overview
Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

FAYE SCHAB
Top achievements
Rank 1
answered on 25 Jun 2013, 02:49 PM
Here's an example of a .Net (Razor) declared Kendo Grid
Basically I want all that goo in the ClientRowTemplate in a template script and be able to reference it by ID as if I had declared this control with javascript. i.e. kendo.template($("#template-id").html()
@(Html.Kendo().Grid(userOrgUnits)
.Name("UserOrgUnitsGrid")
.Columns(columns =>
{
columns.Template(e => { }).ClientTemplate(" ").Title("Org Unit");
columns.Bound(userOrgUnit => userOrgUnit.OrgUnitTypeName).Title("Type").Width(90);
})
.DataSource(dataSource => dataSource
.Ajax())
.Scrollable()
.Resizable(resize => resize.Columns(true))
.ClientRowTemplate(
"#var ouActiveClass = Active ? active_const : inactive_const;#" +
"#var uActiveClass = UserActive ? active_const : inactive_const;#" +
"#isAltRow = ++rowIndex % 2 == 0;# "+
"#var altRowClass = isAltRow ? altRow_const : '';#" +
"<
tr
role
=
'row'
class
=
'#= altRowClass #'
> " +
"<
td
class
=
'userOrgUnit'
>" +
"<
div
class
=
'userOrgUnitName'
><
a
href
=
'/#=OrgUnitTypeName#/details/#=OrgUnitID#'
>#=OrgUnitName #</
a
></
div
>" +
"#if(CustomerName != null){#"+
" <
div
class
=
'userOrgUnitCustomer'
><
a
href
=
'/Customer/details/#=CustomerId#'
>#=CustomerName #</
a
></
div
>" +
"#}#"+
"</
td
>" +
"<
td
>"+
"#=OrgUnitTypeName#" +
"</
td
>" +
"</
tr
>")
)
0
Accepted
Hello again Faye,
I am afraid that such configuration is not supported out of the box. However I can suggest you one of the following approaches.
If you want to stick with the <script type="text/kendo-template"> script element and place your template inside you can use the following:
Another way is to use function instead of template and it could look like this:
I hope this helps.
Regards,
Petur Subev
Telerik
I am afraid that such configuration is not supported out of the box. However I can suggest you one of the following approaches.
If you want to stick with the <script type="text/kendo-template"> script element and place your template inside you can use the following:
//... your other Grid configuration
.ClientRowTemplate(
"#=kendo.template($('\\#myTemplate').html())(data)#"
)
)
<script type=
"text/kendo"
id=
"myTemplate"
>
This is a way to use shared template
#=PersonID #
</script>
Another way is to use function instead of template and it could look like this:
.ClientRowTemplate(
"#=myFormattingFunction(data)#"
)
)
<script type=
"text/javascript"
>
function
myFormattingFunction(model) {
return
"This could be even more convenient to format the row"
+ model.PersonID
}
</script>
I hope this helps.
Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

FAYE SCHAB
Top achievements
Rank 1
answered on 26 Jun 2013, 03:46 PM
Ah, there we go I like those answers.