This question is locked. New answers and comments are not allowed.
Couple issues here. I have a very simple ajax enabled grid in a view that is primarially used in a partial view. I need to conditionally change certain things in the row given certain values in the row. What I origionally came up with based on an article I found on here, was the following:
This worked for the server side binding but does not work with ajax. My understanding on this is that I would need to use ClientTemplate in this particular case. So I came up with the following to append to the server template:
But I am really not understanding how to wrap if statements around that. I tried creating the whole thing as a string and doing the whole <# if (conditions) { #> thing, but the problem is I dont think this process has any awareness of the ProcessingQueue.QueueStatus.ReadyForAssignment property, because Im getting some weird javascript errors when I try to do that. Any ideas? By the way "ActionImage" is just a custom extension that I created that bascially wraps ActionLink to make an image instead.
@(Html.Telerik().Grid<WTC.StatementAutomation.Model.ProcessingQueue>() .Name("ProcessingQueue") .DataBinding(dataBinding => dataBinding .Ajax() .Select("Partial", "ProcessingQueue") ) .RowAction(row => { if (row.DataItem.ProcessingQueueStatus == ProcessingQueue.QueueStatus.ReadyForAssignment) { row.HtmlAttributes["style"] = "background: url(" + Url.Content("~/images/redBlend.png") + ") repeat-x bottom;"; } }) .Columns(columns => { columns.Bound(o => o.Command); columns.Bound(o => o.ProcessTime); columns.Bound(o => o.WorkType); columns.Bound(o => o.Server); columns.Bound(o => o.ProcessingQueueStatus); columns.Bound(o => o.Priority); columns.Bound(o => o.LastUpdated); columns.Template( @<text> @if (item.ProcessingQueueStatus != ProcessingQueue.QueueStatus.ReadyForAssignment) { @Html.ActionImage("Delete", "ProcessingQueue", new { id = item.ProcessingQueueId }, Url.Content("~/Images/control_stop_blue.png"), null) @Html.ActionImage("Bump", "ProcessingQueue", new { id = item.ProcessingQueueId }, Url.Content("~/Images/bullet_arrow_top.png"), null) } </text> )
.Width(46).Title(""); } ) .Pageable() .Sortable(sorting => sorting.Enabled(false)) .Filterable(filter => filter.Enabled(false)) .Groupable(grouping => grouping.Enabled(false)) .Footer(false) )This worked for the server side binding but does not work with ajax. My understanding on this is that I would need to use ClientTemplate in this particular case. So I came up with the following to append to the server template:
.ClientTemplate( Html.ActionImage("Delete", "ProcessingQueue", new { id = "<#=ProcessingQueueId#>" }, Url.Content("~/Images/control_stop_blue.png"), null).ToHtmlString() + Html.ActionImage("Bump", "ProcessingQueue", new { id = "<#=ProcessingQueueId#>" }, Url.Content("~/Images/bullet_arrow_top.png"), null).ToHtmlString() )But I am really not understanding how to wrap if statements around that. I tried creating the whole thing as a string and doing the whole <# if (conditions) { #> thing, but the problem is I dont think this process has any awareness of the ProcessingQueue.QueueStatus.ReadyForAssignment property, because Im getting some weird javascript errors when I try to do that. Any ideas? By the way "ActionImage" is just a custom extension that I created that bascially wraps ActionLink to make an image instead.