This question is locked. New answers and comments are not allowed.
Dear Telerik Team,
I have a grid with custom command and I want to have a confirmation box after the user presses that button. This is the code I've written, but its not working.
Controller:
View:
When I click on the button, it is not triggering the javascript, but it goes to the action method.
Please let me know, what am I missing here?
Cheers
I have a grid with custom command and I want to have a confirmation box after the user presses that button. This is the code I've written, but its not working.
Controller:
public ActionResult BookingHistoryDriver() { return PartialView("_BookingHistoryDriver"); } [GridAction] public ActionResult _BookingHistoryDriver() { //get the personnel id UserInfo ui = (UserInfo)Session["UserInfo"]; SelectHire _selectHire = new SelectHire(); var _bookingHistoryList = _selectHire.HireBookingHistory(ui.PersonnelId); return View(new GridModel { Data = _bookingHistoryList }); } [GridAction] public ActionResult _BookingCancel() { //cancel booking to do //get data to bind grid again SelectHire _selectHire = new SelectHire(); var _bookingHistoryList = _selectHire.HireBookingHistory(1); return View(new GridModel { Data = _bookingHistoryList }); }View:
@(Html.Telerik().Grid<HireBookingHistoryModel>() .Name("BookingHistory") .Sortable(sorting => sorting.Enabled(true)) .Pageable(paging => paging.Enabled(true).PageSize(18)) .Footer(true) .DataKeys(keys => keys.Add(f => f.BOOKING_ID)) .DataBinding(dataBinding => dataBinding.Ajax().Select("_BookingHistoryDriver", "Hire")) .Reorderable(reorder => reorder.Columns(true)) .Resizable(resize=>resize.Columns(true)) .Columns(columns => { columns.Bound(f => f.BOOKING_ID).Title("Booking"); columns.Bound(f => f.FLEET_USER_CODE).Title("Fleet no"); columns.Bound(f => f.REGISTRATION).Title("Registration"); columns.Bound(f => f.START_END_DATE).Title("Dates"); //columns.Bound(f => f.ORIGIN).Title("Origin"); columns.Bound(f => f.DESTINATION).Title("Destination"); columns.Bound(f => f.STATUS).Title("Status"); columns.Command(commands => commands .Custom("cancelBooking") .Text("Cancel") .DataRouteValues(route => route.Add(b => b.BOOKING_ID).RouteKey("bookingId")) .Ajax(true) .Action("_BookingCancel", "Hire")) .Title("Commands") .HtmlAttributes(new { style = "text-align:center" }) .HeaderHtmlAttributes(new { @style = "font-weight:bolder" }); }) )<script type="text/javascript"> $(document).ready(function () { $("a.t-button.t-grid-cancelBooking.t-ajax").click(function (event) { debugger var link = $(this)[0]; if (confirm("Are you sure you want to cancel?")) { $.post(link.href, function (data) { var $grid = $("#Grid").data("tGrid"); $grid.rebind(); }); } return false; }); });</script>When I click on the button, it is not triggering the javascript, but it goes to the action method.
Please let me know, what am I missing here?
Cheers