roadsunknown
roadsunknown

Reputation: 3210

KendoUI Grid Column Template ActionLink

I have an Ajax.ActionLink inside a Kendo Grid Template. I want to click the link, perform the action, and never leave the current view. I was using the Ajax link for confirmation and success messages, but I have also tested normal A and Html.ActionLink as well. In each case, the ActionLink is executes and a blank page is returned. The ActionLink itself calls an export + email function.

Also, the Ajax.ActionLink does not execute its "confirm" command, but no Javascript errors occur. OnSuccess of course does not execute as well. The Ajax.ActionLink outside the Kendo Grid does not execute either of these either.

@(Html.Kendo().Grid(Model.Contacts)
    .Name("contacts")
    .Columns(columns =>
    {
         columns.Bound(e => e.FirstName);
         columns.Bound(e => e.LastName);
         columns.Bound(e => e.Email);
         columns.Template(@<text></text>).ClientTemplate(
            @Ajax.ActionLink("Email Report", "Export", new { EquipmentId = @Model.EquipmentId, WeekDate = @Model.WeekStart.ToString("yyyy-MM-dd"), EmailAddress = "#=Email#" }, new AjaxOptions { HttpMethod = "POST", Confirm = "Are you sure?", OnSuccess = "emailSuccess" }).ToHtmlString()
            );
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .Model(model => { model.Id(e => e.ContactId);})
    )
)

Controller Action:

public ActionResult Export(int EquipmentId, string WeekDate, string EmailAddress)
{
    ...
    return new Extensions.Report.XlsExportResult(...);
}

Action Extension:

public class XlsExportResult : ActionResult
{
    ...
    public override void ExecuteResult(ControllerContext context)
    {
        ...
    }
}

Upvotes: 0

Views: 5326

Answers (1)

roadsunknown
roadsunknown

Reputation: 3210

The Ajax.ActionLink method works...the reason it was not working is I'm an idiot...and the proper scripts were not being bundled for Ajax.

bundles.Add(new ScriptBundle("~/bundles/jqueryajax").Include("~/Scripts/jquery.unobtrusive*"));

Upvotes: 2

Related Questions