Kendoui Grid 在单击编辑按钮时获取选定的行 ID [英] Kendoui Grid Get Selected Row Id when Edit Button is clicked
本文介绍了Kendoui Grid 在单击编辑按钮时获取选定的行 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 Grid 在单击编辑按钮时获取选定的行 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文