如何在不使用 Grid.Select() 的情况下获取 Kendo 网格中一行的 UID
How to Get the UID for a Row in Kendo Grid Without Using Grid.Select()
我们正在使用 Kendo 构建低头数据输入应用程序,并大量使用 Kendo 网格。在网格中使用 selectable='row'
或 selectable='col'
是有问题的,因为用户在不使用鼠标的情况下输入数据,而是使用 Tab 键在网格中导航。视觉 row/cell 选择器不跟随实际的活动行和单元格。
问题:如何获取网格中行的行索引and/oruid关闭并且不使用 grid.select()?
这是网格设置代码:
$("#" + 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);
}
我们正在使用 Kendo 构建低头数据输入应用程序,并大量使用 Kendo 网格。在网格中使用 selectable='row'
或 selectable='col'
是有问题的,因为用户在不使用鼠标的情况下输入数据,而是使用 Tab 键在网格中导航。视觉 row/cell 选择器不跟随实际的活动行和单元格。
问题:如何获取网格中行的行索引and/oruid关闭并且不使用 grid.select()?
这是网格设置代码:
$("#" + 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);
}