This question is locked. New answers and comments are not allowed.
Hi,
I need to use the Ajax.ActionLink helper inside a ClientTemplate for a column in a Telerik MVC Grid, but only if certain condition is true.
This is the code I have used, but it's generating only text in the column, not the link for the action.
If i don't use the conditional sentence, the link is always been shown and it does work fine, but i need that logic to show or hide the link for the action.
What am i doing wrong ?
Here is the full definition of the grid, just in case:
Thanks in advance
I need to use the Ajax.ActionLink helper inside a ClientTemplate for a column in a Telerik MVC Grid, but only if certain condition is true.
This is the code I have used, but it's generating only text in the column, not the link for the action.
.ClientTemplate(@" <#= !CheckListForThisYearSubmitted?" + Ajax.ActionLink("Unsubmit checklist", "SubmitCheckList", new { enable = false, id = 1 }, new AjaxOptions { UpdateTargetId = "generalDivTest" }).ToString() + ":'' #> ")
If i don't use the conditional sentence, the link is always been shown and it does work fine, but i need that logic to show or hide the link for the action.
What am i doing wrong ?
Here is the full definition of the grid, just in case:
@(Html.Telerik().Grid(Model) .Name("GridPersonBusiness") .DataKeys(dataKeys => dataKeys.Add(c => c.ID)) .Columns(columns => { columns.Bound(o => o.Name); columns.Bound(o => o.UTR); columns.Bound(o => o.TypeOfClient).Width(160); columns.Bound(o => o.HasDataFromPreviousYears).Title("Data previous years") .ClientTemplate(@" <input type=""checkbox"" <#= HasDataFromPreviousYears?'checked=""true""':'' #> disabled=""disabled"" />").Width(160); columns.Template( @<text> <input name="checkedRecords" type="checkbox" value="@item.ID" title="checkedRecords" @if (item.CheckListForThisYearCreated) { <text>disabled="disabled"</text> } /> </text>).ClientTemplate(@" <input name=""checkedRecords"" type=""checkbox"" value=<#= ID #> title=""checkedRecords"" <#= CheckListForThisYearCreated? disabled='disabled' : '' #> />") .Title("Create checkList").Width(160); columns.Template( @<text> @if (item.CheckListForThisYearSubmitted) { <text>CheckList submitted - </text>@* @Html.ActionLink("Unsubmit", "SubmitCheckList", new { id = item.ID, enable = "false" })*@ @Ajax.ActionLink("Unsubmit", "SubmitCheckList", new { id = item.ID, enable = "false" }, new AjaxOptions { UpdateTargetId = "generalDivTest" }) } else if (item.CheckListForThisYearCreated) { @* <text><a href="/CheckList/FillOnlineForm/@item.ID" >Online checklist</a></text> <text><a href="/CheckList/GetHardCopy/@item.ID">Hardcopy checklist</a></text> @Html.ActionLink("Delete checklist", "DeleteCheckList", new { id = item.ID })*@ @Ajax.ActionLink("Fill Online Checklist NEW", "FillOnlineForm", new { id = item.ID }, new AjaxOptions { UpdateTargetId = "generalDivTest" }) @Ajax.ActionLink("Hardcopy Checklist NEW", "GetHardCopy", new { id = item.ID }, new AjaxOptions { UpdateTargetId = "generalDivTest" }) @Ajax.ActionLink("Delete checklist NEW", "DeleteCheckList", new { id = item.ID }, new AjaxOptions { UpdateTargetId = "generalDivTest" }) } </text>) .ClientTemplate(@" <#= !CheckListForThisYearSubmitted?" + Ajax.ActionLink("Unsubmit checklist", "SubmitCheckList", new { enable = false, id = 1 }, new AjaxOptions { UpdateTargetId = "generalDivTest" }).ToString() + ":'' #> ") .Title("Submission"); }) .DataBinding(dataBinding => { dataBinding.Ajax().Select("_AjaxGetCheckLists", "CheckList"); }) .Sortable() .Selectable() .Pageable(paging => paging.Style(GridPagerStyles.Status).PageOnScroll(true))//.Pageable(a => a.PageSize(10)) .Filterable() .Footer(true));Thanks in advance