This is a migrated thread and some comments may be shown as answers.

Handle Edit/Delete in MVC Action

1 Answer 279 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Support
Top achievements
Rank 1
Support asked on 19 May 2013, 08:12 PM
Hi there,

I am using the KendoUI grid control on two MVC views where the user needs the ability to edit the data on each grid. The proposed solution is to redirect to an "Edit" and "Delete" view if the user clicks on the "Edit" or "Delete" buttons.

I currently have this working for one of the grids, but the second grid only allows me to edit the data inline. The definition of the grids are identical (apart from the columns, model, and actions).

How can I disable the inline editing of the second grid so that it redirects to an MVC view instead?

This code works as expected and redirects to the "Edit" and "Delete" views.
<%:Html.Kendo().Grid(Model)
.Name("players")
.Columns(columns =>
{
    columns.Bound(p => p.FullName);
    columns.Bound(p => p.MobilePhone);
    columns.Bound(p => p.EmailAddress);
    columns.Command(command =>
    {
        command.Edit();
        command.Destroy();
    }).Width(200);
})
.DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Model(model => model.Id(p => p.PlayerId))
        .Read(read => read.Action("Edit", "Player"))
        .Update(update => update.Action("Edit", "Player"))
        .Destroy(update => update.Action("Delete", "Player")))
%>


This code DOES NOT work as expected and performs an in-line edit
<%:Html.Kendo().Grid(Model)
    .Name("articles")
    .Columns(columns =>
    {
        columns.Bound(a => a.Date);
        columns.Bound(a => a.Title);
        columns.Command(command =>
        {
            command.Edit();
            command.Destroy();
        }).Width(200);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Model(model => model.Id(a => a.ArticleId))
        .Read(read => read.Action("Edit", "Article"))
        .Update(update => update.Action("Edit", "Article"))
        .Destroy(destroy => destroy.Action("Delete", "Article")))
%>

1 Answer, 1 is accepted

Sort by
0
Accepted
Support
Top achievements
Rank 1
answered on 19 May 2013, 09:08 PM

Resolved

I changed the .Ajax() to .Server() and this seems to work, but it does not explain why the first "players" grid was working as expected, even though it was configured with .Ajax(). Can anyone explain this?

Tags
Grid
Asked by
Support
Top achievements
Rank 1
Answers by
Support
Top achievements
Rank 1
Share this question
or