2012-09-10 16 views
1

我在我的MVC 3.0應用程序中有一個telrik網格。在網格中,我想根據日期禁用我的一列。如何使用電網中的條件

{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) 

我在模型帶來從DB &的expiray日期如果到期日期小於或今天的日期已過的到期日期(即DateTime.Now),則上述柱的鏈路需要的特性被禁用或該列中的數據(即鏈接)需要被禁用,它不會被點擊

任何幫助將不勝感激。

回答

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

請考慮爲您的答案添加解釋,並/或在問題提供的代碼中包含您的代碼片段。 –

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

這是工作和測試實例。