本文介绍了单击“编辑"按钮时,Kendoui网格获取选定的行ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的网格,使用JQuery单击编辑按钮时,在收集PersonID时遇到很多麻烦.我需要PersonID,因为我要将文件上传添加到内联编辑列中,并且我想上传文件并将其与PersonID关联.欢迎所有帮助:)

I have a simple grid and I'm having a lot of trouble collecting the PersonID when the edit button is clicked using JQuery. I need the PersonID because I'm going to add a file upload to the inline edit column and i want to upload a file and associate it with the PersonID. All help welcome :)

@(Html.Kendo().Grid<GridCustomPopupTemplate.Models.Person>().Name("Grid")
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(m => m.PersonID))
        .Read(read => read.Action("GetPersons", "Home"))
        .Update(up => up.Action("UpdatePerson", "Home"))
)

.Columns(columns =>
{
    columns.Bound(c => c.PersonID).Width(200);
    columns.Bound(c => c.Name);
    columns.Command(cmd => cmd.Edit());
})

.Pageable()
.Sortable()
.Editable(ed => ed.Mode(GridEditMode.InLine))
.Events(ev => ev.Edit("doOnRowSelect"))
)



<script type="text/javascript">

function doOnRowSelect(e) {

     alert(The #PersonID# of the row which we are going to edit here....)

}

</script>

推荐答案

我使用以下JavaScript进行了此工作:

I got this working by using the following JavaScript:

$("body").on("click", "[role='row']", function (e) {

    var grid = $("#Grid").getKendoGrid();
    var item = grid.dataItem($(e.target).closest("tr"));
    alert(item.PersonID);

});

这篇关于单击“编辑"按钮时,Kendoui网格获取选定的行ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 18:38