最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Get the UID for a Row in Kendo Grid Without Using Grid.Select() - Stack Overflow

programmeradmin3浏览0评论

We are building a heads-down data entry application using Kendo, and make heavy use of Kendo Grid. Using selectable='row' or selectable='col' in the grid is problematic because the user is entering data without using the mouse, but navigating the grid using tab key. The visual row/cell selector does not follow the actual active row and cell.

Question: How can I get the row index and/or the uid of the row in the grid with selectable turned off and without using grid.select()?

Here's the grid setup code:

            $("#" + 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);
     }

We are building a heads-down data entry application using Kendo, and make heavy use of Kendo Grid. Using selectable='row' or selectable='col' in the grid is problematic because the user is entering data without using the mouse, but navigating the grid using tab key. The visual row/cell selector does not follow the actual active row and cell.

Question: How can I get the row index and/or the uid of the row in the grid with selectable turned off and without using grid.select()?

Here's the grid setup code:

            $("#" + 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);
     }
Share Improve this question edited Feb 27, 2016 at 3:48 A2MetalCore asked Apr 23, 2015 at 21:42 A2MetalCoreA2MetalCore 1,6394 gold badges27 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Use whatever means you have at hand to resolve the row element the user is currently on and then simply do:

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

If I'm understanding your question correctly, this will be

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

If I misunderstood, please elaborate.

Answer: You can reference the uid field directly using e.model.uid. For example:

       $("#" + 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);
 }
发布评论

评论列表(0)

  1. 暂无评论