I'm having a very hard time figuring out the syntax to correctly handle if the Email is null then display nothing. The phone column works fine for finding and so does '' : 'a' in the ClientTemplate, however, using what I have below I continuously get Uncaught Error: Invalid template:
Any help fixing the syntax would be greatly appreciated.
@(Html.Kendo().Grid <MVCSite.Model.ProspectSearchContact> ()
.Name("gridContacts_#=ProspectId#") // template expression, to be evaluated in the master context
.Columns(columns => {
columns.Bound(o => o.Id).Width(150).Visible(false);
columns.Bound(o => o.ContactName).Title("Name").Width(100);
columns.Bound(o => o.ContactType).Width(150);
columns.Bound(o => o.Email).ClientTemplate("#= Email == null ? '' : '<a href='mailto:\\#= Email \\#'>\\#= Email \\#</a>'");
columns.Bound(o => o.Phone).ClientTemplate("<a href='tel:\\#= Phone \\#'>\\#= Phone \\#</a>").Width(150);
})
.ToolBar(toolbar => toolbar.Create())
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.Id);
model.Field(p => p.ProspectId).Editable(false);
})
.PageSize(5)
.Create(update => update.Action("NoteInsert", "DataSource", new {
ProspectId = "#=ProspectId#"
}))
.Read(read => read.Action("ProspectGridItemDataSource", "ProspectingDataSource", new {
Id = "#=ProspectId#", dataType = "Contact"
}))
.Update(update => update.Action("EditingPopup_Update", "Grid"))
.Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
)
.Pageable()
.Sortable()
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("GridContactEntry"))
.ToClientTemplate()