MVC Telerik Grid Conditional column value?

How can I get this working in MVC Telerik Grid Control

columns.Template(e => { if (e.EndDate>DateTime.Now ) { @Html.ActionLink("Stop", "StopMedication", "Medication", new { id = e.PrescriptionID }, new { @class = "standard button" }) } else { @Html.ActionLink("Renew", "RenewMedication", "Medication", new { id = e.PrescriptionID }, new { @class = "standard button" }) } }); 
+6
source share
1 answer

The following snippet should work fine in the Telerik grid template column using Razor syntax:

  columns.Template( @<text> @if (@item.EndDate > DateTime.Now) { @Html.ActionLink("Stop", "StopMedication", "Medication", new { id = @item.PrescriptionID }, new { @class = "standard button" }) } else { @Html.ActionLink("Renew", "RenewMedication", "Medication", new { id = @item.PrescriptionID }, new { @class = "standard button" }) } </text> ); 

Using @<text></text> inside the template, as well as using the @item object that represents the current element (the object attached to the string) and its properties, will allow you to run this template.

+11
source

Source: https://habr.com/ru/post/899269/


All Articles