javascript 使用 jquery 从剑道网格中获取单元格值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22148067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get cell value from kendo grid using jquery
提问by User
How to get the kendo grid cell value using jquery function?Am new to kendo grid
如何使用 jquery 函数获取剑道网格单元格值?我是剑道网格的新手
{field:abc,title:values}
I need the abc value in javascript or jquery?
我需要 javascript 或 jquery 中的 abc 值吗?
回答by CSharper
I assume your using single row selection for the Grid. This piece of code will grab any value you need off of the selected row.
我假设您对网格使用单行选择。这段代码将从所选行中获取您需要的任何值。
$('#ProposalGrid').click(function () {
var gview = $(this).data("kendoGrid");
var selectedItem = gview.dataItem(gview.select());
var Guid = selectedItem.YourPropertyName;
})
selectedItem gives you access to all the properties on your model
selectedItem 使您可以访问模型上的所有属性
回答by Pratik M. Kansara
If anyone still looking for an answer then you can try using following steps:
如果有人仍在寻找答案,那么您可以尝试使用以下步骤:
Note:Basically KendoGrid all rows have it's unique uid property assigned for identify each row. So if you are having uid then you can follow these steps:
注意:基本上 KendoGrid 的所有行都分配了唯一的 uid 属性来标识每一行。因此,如果您有 uid,那么您可以按照以下步骤操作:
var grid = $("#grid").data("kendoGrid");
var tr = grid.dataSource.getByUid("your-row-uid");
var yourFieldValue = tr.yourFieldName;
Even you can get value throught following steps:
即使您可以通过以下步骤获得价值:
First :
第一的 :
var grid = $("#grid").data("kendoGrid");
Second :
第二 :
var dataItem = grid.dataItem(grid.select());
or
或者
var dataItem = grid.dataItem($(event.target).closest("tr"));
or
或者
var dataItem = grid.dataItem("tr.k-grid-edit-row");
Third:
第三:
var yourFieldValue = dataItem.yourFieldName;