Javascript 从剑道网格中获取并警告select记录的ID

Javascript 从剑道网格中获取并警告select记录的ID,javascript,asp.net-mvc,kendo-ui,kendo-grid,Javascript,Asp.net Mvc,Kendo Ui,Kendo Grid,我在MVC应用程序中运行剑道网格,在javaScript中运行警报功能。我不能对工作保持警惕;i、 e.所选记录的ID。我不确定我在代码中做错了什么 JavaScript 剑道格网 @(Html.Kendo().Grid()) .Name(“所有函数网格02”) .列(列=> { column.Bound(c=>c.Function\u id); column.Bound(c=>c.FunctionName); column.Bound(c=>c.Hierarchy\u Level); col

我在MVC应用程序中运行剑道网格,在javaScript中运行警报功能。我不能对工作保持警惕;i、 e.所选记录的ID。我不确定我在代码中做错了什么

JavaScript 剑道格网

@(Html.Kendo().Grid())
.Name(“所有函数网格02”)
.列(列=>
{
column.Bound(c=>c.Function\u id);
column.Bound(c=>c.FunctionName);
column.Bound(c=>c.Hierarchy\u Level);
column.Bound(c=>c.ControllerName);
column.Bound(c=>c.ActionName);
Command(Command=>Command.Custom(“视图”)。单击(“DeleteFunctionNavigation”);
})
.HtmlAttributes(新的{style=“height:380px;”})
.Editable(可编辑=>Editable.Mode(GridEditMode.PopUp))
.Scrollable()
.可过滤()
.Groupable()
.Sortable()
.可选(可选=>可选
.模式(GridSelectionMode.Single))
.Pageable(Pageable=>Pageable
.刷新(真)
.页面大小(真)
.按钮计数(5))
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“GetAllFunctions”、“SystemCore”))
.Model(Model=>Model.Id(c=>c.Function\u-Id))
)
.Events(Events=>Events.DataBound(“DataBound”))
)

我已经创建了一个JSFIDLE--

代码:-

 $("#grid tr").click(function() {
     var entityGrid = $("#grid").data("kendoGrid");

     var selectedItem = entityGrid.dataItem(entityGrid.select());

     alert(selectedItem.id);

 });
使用上述代码,它工作正常

我已经用(本演示中的网格)尝试了上面给定的代码,并将下面给定的代码放在控制台中,然后选择行,然后显示警报

$("#rowSelection tr").click(function() {
    var entityGrid = $("#rowSelection").data("kendoGrid");

    var selectedItem = entityGrid.dataItem(entityGrid.select());

    alert(selectedItem.ShipCountry);

});

为什么当我为selectedItem执行操作时,会得到null---var-selectedItem=entityGrid.dataItem(entityGrid.select());--警报(selectedItem)我发现问题是!!如果选择了行,则我的代码发送id,但我想使用按钮未选择行。如果需要,则处理网格或onSelect的更改事件
 $("#grid tr").click(function() {
     var entityGrid = $("#grid").data("kendoGrid");

     var selectedItem = entityGrid.dataItem(entityGrid.select());

     alert(selectedItem.id);

 });
$("#rowSelection tr").click(function() {
    var entityGrid = $("#rowSelection").data("kendoGrid");

    var selectedItem = entityGrid.dataItem(entityGrid.select());

    alert(selectedItem.ShipCountry);

});