Hello
I am trying out Kendo for MVC and I'm having some difficulties with a custom URL action.
Previously I used DataTables in which I had a column for Edit, Details and Delete options which triggers the record to edit and a JavaScript function that initializes a partial view popup where I can edit, view or delete the record.
Here is an example of the code from the column inside DataTables that I used:
return
'<a href="@Url.Action("Edit", "Country")?id='
+ data +
'" class="editCountry">Edit</a>
;
And here is the JavaScript function that us triggered when I click on Edit:
$(
'#countriesTable'
).on(
"click"
,
".editCountry"
,
function
(event) {
event.preventDefault();
var
url = $(
this
).attr(
"href"
);
$.get(url,
function
(data) {
$(
'#editCountryContainer'
).html(data);
$(
'#editCountryModal'
).modal(
'show'
);
});
});
Here is my current code for the edit button inside the Kendo Grid:
columns.Template(@<text>Actions</text>).ClientTemplate(
"<a href='"
+ Url.Action(
"Edit"
,
"Country"
) +
"/#=CountryIdentifier#'>Edit</a>"
);
When I click on the edit button it tries to edit the record on a new page which obviously won't work because I'm using a partial view.
How can I trigger the same JavaScript function I used in my DataTables Column inside my Kendo Grid Column?
Thanks