[英]How to Get the UID for a Row in Kendo Grid Without Using Grid.Select()
我们正在使用Kendo构建平淡无奇的数据输入应用程序,并大量使用Kendo Grid。 在网格中使用selectable='row'
或selectable='col'
是有问题的,因为用户无需使用鼠标即可输入数据,而是使用Tab键导航网格。 可视行/单元格选择器不跟随实际的活动行和单元格。
问题:如何在不使用grid.select()的情况下关闭selectable的情况下获取网格中的行索引和/或行的uid ?
这是网格设置代码:
$("#" + target).kendoGrid({
dataSource: gridDs,
edit: gridCellEdit,
height: applet.height,
editable: {
createAt: 'bottom'
},
filterable: true,
sortable: true,
navigatable: true,
resizable: true,
reorderable: true,
scrollable: { virtual: true },
columns: gridColumns,
dataBound: monitorKeyboard
}
});
function gridCellEdit(e) {
var uid = $('#grid_active_cell').closest('tr').data('uid');
console.log(uid);
}
使用现有的任何方法来解决用户当前所在的行元素,然后只需执行以下操作:
$(target-tr).data('uid');
如果我正确理解了您的问题,这将是
$('#grid_active_cell').closest('tr').data('uid');
如果我误会了,请详细说明。
答:您可以使用e.model.uid直接引用uid字段。 例如:
$("#" + target).kendoGrid({
dataSource: gridDs,
edit: gridCellEdit,
height: applet.height,
editable: {
createAt: 'bottom'
},
filterable: true,
sortable: true,
navigatable: true,
resizable: true,
reorderable: true,
scrollable: { virtual: true },
columns: gridColumns,
dataBound: monitorKeyboard
}
});
function gridCellEdit(e) {
console.log(e.model.uid);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.