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

Editor template if statements

1 Answer 583 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chrys
Top achievements
Rank 1
Chrys asked on 24 Jun 2013, 05:17 AM
In my grids I have partials views as my editor templates. In the these editor templates I try to check the values on create and edit using razor if statements. These statements do not seem to work for grid editor templates. Here is an example
@if(Model.UserName!=null)
{
@Html.LabelFor(m=>m.Username)
}
else
{
@Html.TextBoxFor(m=>m.UserName)
}

The if always seems to fail is this because after the template is rendered these statements are no longer there and cannot be reached?

Is the only way to accomplish my task is by altering these elements via jquery in the grid edit event?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 25 Jun 2013, 03:40 PM
Hi Chrys,

You can use JavaScript if-else statements inside Kendo template definition. This help article demonstrates the syntax:
I hope the approach will fit in your scenario.

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