Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:58:29+00:00 2026-06-08T11:58:29+00:00

I have a simple Telerik Grid for ASP.NET MVC with Ajax delete command. The

  • 0

I have a simple Telerik Grid for ASP.NET MVC with Ajax delete command. The deleting works, however, the page displays an error, and doesn’t update.

I would also like to call custom JavaScript upon AJAX call return, but can’t figure out where to put the code.

Here’s the view:

Html.Telerik()
    .Grid<ScenarioVm>(Model)
    .Name("scenarioGrid")
    .DataBinding(dataBinding => dataBinding
        .Ajax()
        .Delete("Delete", "Scenario")
        .Select("Index", "Scenario"))
    .DataKeys(keys => keys.Add(c => c.Id))
    .Columns(columns =>
    {
        columns.Template(o => o.Name)
            .Title("Scenario")
            .FooterTemplate(@<text>Total @Model.Count()</text>);
        columns.Bound(o => o.IsLocked);
        columns.Bound(o => o.ContractMonth);
        columns.Bound(o => o.CreateDate);
        columns.Command(commands => commands
                .Delete()
                .ButtonType(GridButtonType.Image))
            .Title("Delete");
    })
    .Sortable()
    .Scrollable(scroll => scroll.Height(200))
    .ClientEvents(events => events.OnDelete("onDelete")))

The Javascript that gets called before the AJAX call:

function onDelete(e) {
    var scenario = e.dataItem;
    if (scenario.CanDelete == false) {
        alert("Can not delete " +
            e.dataItem.Name +
            ": there exists a solution!");
        return false;
    } else {
        $.blockUI({
            css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
        });
        return true;
    }
}

Controller method:

[HttpPost]
[GridAction]
public ActionResult Delete(Scenario scenario)
{
    Logger.Info("Delete scenario " + scenario);
    if (scenario == null)
    {
        return new EmptyResult();
    }

    try
    {
        _scenarioRepository.Delete(scenario);
        Logger.Info("Successfully deleted " + scenario);
    }
    catch(Exception e)
    {
        Logger.Error(scenario + e.Message, e);
        var result = new JsonResult
        {
            JsonRequestBehavior = JsonRequestBehavior.DenyGet,
            Data = new {
                ErrorCode = 1,
                ErrorMessage = e.GetType() + ": " + e.Message
            }
        };

        return result;
    }

    return new EmptyResult();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:58:31+00:00Added an answer on June 8, 2026 at 11:58 am

    If I understood the question correctly you want to javascript function to be executed when operation is done. Last row in the example source code is to define callback for OnComplete event.

    .ClientEvents(events => events
                .OnLoad("onLoad")
                .OnEdit("onEdit")
                .OnDetailViewCollapse("onDetailViewCollapse")
                .OnDetailViewExpand("onDetailViewExpand")
                .OnDelete("onDelete")
                .OnSave("onSave")
                .OnDataBinding("onDataBinding")
                .OnRowDataBound("onRowDataBound")
                .OnRowSelect("onRowSelect")
                .OnDataBound("onDataBound")
                .OnColumnResize("onColumnResize")
                .OnColumnReorder("onColumnReorder")
                .OnComplete("onComplete"))
    

    Telerik documentation has also an example how to define OnComplete event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple page that pops up a telerik radwindow on button click.
I'm using the Telerik Extensions for ASP.NET MVC 3 and I'm having a problem
In a ASP.NET MVC 4 app I have a view with a paged list
I have a query in regards to a Telerik RadGrid in ASP.NET. I have
I currently have a Telerik MVC Grid that is populated with Patients. What I
If you are using ASP.NET MVC how are you doing grid display? Rolled your
mvc3, telerik mvc 2011.2.712 I have a grid with a DetailView. In the DetailView,
I have an ASP.NET application that renders a 3rd party (Telerik's) menu control under
I have an ASP.NET web application that I am making and I am thinking
I need to implement a grid in asp.net that behaves almost exactly like MS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.