userhex
userhex

Reputation: 13

how to use conditions in telerik grid

I am having a telrik grid in my MVC 3.0 application. In grid I want to disable one of my column based on dates .

{Html.Telerik().Grid(Model.PostedDocument)
.Name("PostedDocumentsGrid")
.HtmlAttributes(new { @class = "grid scroll-pane" }) 
.Columns(columns =>
{
columns.Bound(o => o.DocumentLabel).Title(ResourceHelper.GetMessage("Posted_DocumentName")).Template(@<text><a href="@Url.Action("DownloadDocument", "ConsentAndDocument", new { documentId = @item.DocumentId })">@item.DocumentLabel</a></text>).Width(180)

I have a property in model which brings the expiray date from DB & if the expiry date is less or todays date has passed the expiry date (i.e DateTime.Now) then the link of the above column needs to be disabled or the data in that column(i.e links) needs to be disabled , it shud not get clicked

Any help will be appreciated.

Upvotes: 1

Views: 1622

Answers (2)

Marek Bar
Marek Bar

Reputation: 903

 cols.Bound(col => col.isAvailable)
      .ClientTemplate("<# if(isAvailable) { #> in stock <#} else { #> no <# } #>")
      .Title("Available")
      .HtmlAttributes(new { @title="Is available now?" });

This is working and tested example.

Upvotes: 0

seyfside
seyfside

Reputation: 117

.ClientTemplate("<#if(condition){#><a href=\"WaitingApprove/<#= LatestVersionId #>\">" + "if link" + "</a><# }
 else{#><a href=\"Edit/<#= Id #>\">" + "else link" + "</a> <# } #>")

Upvotes: 1

Related Questions