How can i get this work 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" })
}
});
The following snippet should work perfectly 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>
);
Taking use of the @<text></text>
inside of the template, as well as using the @item object, which represents the current item (entity tied to the row) and it's properties, will allow you to have this template up and running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With