【问题标题】:How to Get the UID for a Row in Kendo Grid Without Using Grid.Select()如何在不使用 Grid.Select() 的情况下获取 Kendo Grid 中一行的 UID
【发布时间】:2015-04-23 21:42:06
【问题描述】:

我们正在使用 Kendo 构建一个低头数据输入应用程序,并大量使用 Kendo Grid。在网格中使用selectable='row'selectable='col' 是有问题的,因为用户在不使用鼠标的情况下输入数据,而是使用tab 键在网格中导航。可视行/单元格选择器不跟随实际的活动行和单元格。

问题:在不使用 grid.select() 的情况下,如何在不使用 grid.select() 的情况下获取网格中行的 行索引 和/或 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);
     }

【问题讨论】:

    标签: javascript kendo-ui kendo-grid


    【解决方案1】:

    使用您手头的任何方法来解析用户当前所在的行元素,然后只需执行以下操作:

    $(target-tr).data('uid');
    

    如果我正确理解了您的问题,那将是

    $('#grid_active_cell').closest('tr').data('uid');
    

    如果我理解错了,请详细说明。

    【讨论】:

    • @ASA2 在这种情况下,您需要提供一个工作示例来说明您的问题。
    【解决方案2】:

    Answer: 可以直接使用 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);
     }
    

    【讨论】:

      猜你喜欢
      • 2017-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多