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

Kendo Grid MVC beforeEdit

2 Answers 1049 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 10 Aug 2017, 07:49 PM

Hello,

The only way we can access the beforeEdit Event on a kendo grid is with javascript. shouldnt this be accessible through the Kendo.Mvc.UI.Fluent.GridEventBuilder? attached are just images showing that it errors and that we are using Kendo version 2017.2.621.340 as our dll.

 

the way we did get it to work is by binding it via javascript with this code (for anyone that wants to know how to get this event to work)

    $(document).ready(function () {
        var grid = $("#BrandsGrid").data("kendoGrid");
      
        grid.bind("beforeEdit", function (e) {
            alert("Before Edit");
        });

    })

but its weird to have 2 of your events using the grid builder and then 1 of your events bound through javascript makes it easy for a developer to miss that the event exists which can lead to them not fully understanding what is happening upon editing the grid.

 

Thanks,

Thomas

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 14 Aug 2017, 01:43 PM
Hello Thomas,

This is a known issue and the developers have included a fix for it. It will be available in the next official release. 

Until the new release is available you can use the JavaScript syntax to add handler for the beforeEdit event:


$(function () {
    var grid = $("#grid").getKendoGrid();
    grid.bind("beforeEdit", beforeEditHandler);
 
    function beforeEditHandler(e) {
        alert("before edit");
    }
})


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Sarah
Top achievements
Rank 1
Iron
answered on 25 Oct 2021, 12:25 PM

For anyone else struggling to find the latest documentation as I was, you can find it here
https://docs.telerik.com/aspnet-mvc/api/Kendo.Mvc.UI.Fluent/GridEventBuilder#beforeeditsystemfuncsystemobjectsystemobject


@(Html.Kendo().Grid()
    .Name("Grid")
    .Events(events => events.BeforeEdit(
            @<text>
                function(e) {
                //event handling code
                }
                </text>
                ))
            )

or


@(Html.Kendo().Grid()
    .Name("Grid")
    .Events(events => events.BeforeEdit("gridBeforeEdit"))
)

Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Sarah
Top achievements
Rank 1
Iron
Share this question
or