@model ACS.CSG.ReviewContentManager.Models.ClientViewModel
@(Html.Telerik().Grid<ACS.CSG.ReviewContentManager.Models.ContactViewModel>()
.Name("Contacts")
.DataKeys(k => k.Add(o => o.ID))
.ToolBar(cmd =>
{
cmd.Insert().ButtonType(GridButtonType.ImageAndText);
})
.DataBinding(dataBinding => dataBinding.Ajax()
.OperationMode(GridOperationMode.Client)
.Delete("_ContactDeleteAjax", "Client")
.Insert("_ContactInsertAjax", "Client")
.Update("_ContactUpdateAjax", "Client")
.Select("_ContactsForClientAjax", "Client")
)
.Columns(columns =>
{
columns.Bound(c => c.Active)
.Filterable(false)
.Title(String.Empty)
.ClientTemplate("<img alt='<#= Active ? '' : 'Inactive' #>' height='24' src='"
+ Url.Content("~/Content/Common/Images/Icons/")
+ "<#= Active ? 'in use' : 'disabled' #>.png' width='24' />")
.Width(48);
columns.Bound(c => c.ID);
columns.Bound(c => c.FirstName);
columns.Bound(c => c.LastName)
.ClientTemplate("<#= LastName #>"
+ "<button class=\"grid-row-action-button right\" style=\"display: none\" onclick=\"ContactGrid_showRowAction(event, '<#= ID #>');\">▼</button>"
+ Html.Telerik().Menu()
.Name("contactrowActionMenu_<#= ID #>")
.HtmlAttributes(new { @class = "grid-row-action-menu" })
.Orientation(MenuOrientation.Vertical)
.Items(items =>
{
items.Add()
.Text("Edit")
.ImageUrl("~/Content/Common/Images/Icons/edit.png")
.ImageHtmlAttributes(new { style = "width: 24px; height: 24px;" });
items.Add()
.Text("Delete")
.ImageUrl("~/Content/Common/Images/Icons/recycle.png")
.ImageHtmlAttributes(new { style = "width: 24px; height: 24px;" });
})
.ClientEvents(events => events.OnSelect("contactmenuSelect"))
);
columns.Bound(c => c.Phone);
columns.Bound(c => c.Email);
})
.ClientEvents(events => events
.OnLoad("ContactGrid_onLoad")
.OnDataBound("ContactGrid_onDataBound")
.OnError("ContactGrid_onError")
.OnRowSelect("ContactGrid_onRowSelect")
)
.ColumnContextMenu()
.Editable(editing => editing.Enabled(true).Mode(GridEditMode.PopUp))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(false))
.KeyboardNavigation()
.Pageable(paging => paging.Enabled(false))
.Scrollable(scrolling => scrolling.Enabled(true))
.Selectable(selecting => selecting.Enabled(true))
.Sortable(sorting => sorting.Enabled(true).SortMode(GridSortMode.SingleColumn))
)
THIS IS THE FUNCTION I NEED TO PASS THE MODEL ID INTO:
function contactmenuSelect(e, id) {
if (e.item.textContent == 'Delete') {
$('#Contacts').data('tGrid').deleteRow($(e.currentTarget).parent().parent());
}
if (e.item.textContent == 'Edit') {
$('#Contacts').data('tGrid').editRow($(e.currentTarget).parent().parent());
}
}
Thanks!