I am having trouble getting my 'Edit' link in a row of a
grid to get the row's ID so that I can fire my JavaScript. I'm doing it this way because I need to call a different controller, but just for the 'Edit' link and not the 'Details' or 'Delete' links.
This is my Grid and JavaScript code:
@(Html.Kendo().Grid(Model)
.Name("facilityContactGrid")
.Columns(columns =>
{
columns.Bound(c => c.ContactLastName).Width(174);
columns.Bound(c => c.ContactFirstName).Width(140);
columns.Bound(c => c.ContactTitleDescription).Width(223);
columns.Bound(c => c.ContactPhoneNumber).Width(108);
columns.Bound(c => c.ContactActiveFlag).Width(95);
columns.Bound(c => c.PrimaryContactFlag).Width(107);
columns.Bound(c => c.ContactID)
.ClientTemplate(Html.ActionLink("Details", "Details", new { ContactID = "#=ContactID#" })
.ToHtmlString())
.Title("Details")
.Width(93);
columns.Bound(c => c.ContactID)
.Title("Edit")
.Filterable(false)
.ClientTemplate("<
a
onclick=\"EditFacilityContact(this,'#= ContactID #')\"
href
=
'\\#'
>Edit</
a
>");
columns.Bound(c => c.ContactID)
.ClientTemplate(Html.ActionLink("Delete", "Delete", new { ContactID = "#=ContactID#" })
.ToHtmlString())
.Title("Delete")
.Width(97);
}).Editable(editable => editable
.DisplayDeleteConfirmation("Are you sure you want to delete this item?"))
.Pageable()
.Resizable(resize => resize.Columns(true))
.Sortable()
.Scrollable(scr => scr.Height(470))
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.ContactID))
.PageSize(15)
.ServerOperation(false))
)
<
script
type
=
"text/javascript"
>
function EditFacilityContact() {
var grid = $("#facilityContactGrid").data("kendoGrid"); // THIS IS WORKING
alert("YOU ARE HERE!!");
return false;
}
</
script
>
I'm I have tried using grid.select() and various forms of that, but none of the rows are "selected", I'm just clicking the 'Edit' link.
Any help with this will be greatly appreciated.