2
votes

I want to get the edit row ID on Edit button click on kendo grid.

enter image description here

When i click on the edit button i want to get "Document Type ID" which is shown in the grid and it has to be hidden in the original grid(primary key of datasource). I have shown it to clarify my issue.

below event fires on edit click but I have not been able to get the ID of that particular row.

$("#grid").data("kendoGrid").bind("edit", function (e) {

            var grid = $("#grid").data("kendoGrid");


        });

@(Html.Kendo().Grid((IEnumerable<Doc.Web.Models.Common.DocumentTypeModel>)Model.lst_DocumentType)    
    .Name("grid")
    .Columns(columns =>
    {

        columns.Bound(o => o.DocumentTypeID).Visible(false);
        columns.Bound(o => o.DocumentType).Title("Document Type");
        columns.Bound(o => o.DocumentTypeDescription).Title("Description");

        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(182);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))//.TemplateName("DocumentType_template"))    
    .Pageable()
    .Sortable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.DocumentTypeID))
        .Create(update => update.Action("EditingInline_Create", "DocumentType").Data("additionalInfo"))
        .Read(read => read.Action("EditingInline_Read", "DocumentType").Data("additionalInfo"))
        .Update(update => update.Action("EditingInline_Update", "DocumentType").Data("additionalInfo"))
        .Destroy(update => update.Action("EditingInline_Destroy", "DocumentType").Data("additionalInfo"))

    )
)
1

1 Answers

3
votes

Inside the edit event of the Grid you can get reference to the row model via the arguments object.

function onEdit(e){
     alert(e.model.DocumentTypeID);
}