AG网格编辑单元格上的触摸事件

时间:2016-03-23 12:57:09

标签: javascript touch ag-grid

我无法在ag-grid上编辑单元格以处理手机或平板电脑上的触摸事件,只需点击鼠标即可正常工作。

我也无法将列拖动到工具栏中的枢轴选项中以使用触摸功能。

无论如何围绕这个?

1 个答案:

答案 0 :(得分:1)

所以我设法通过对库进行非常小的编辑来修复单元格的编辑:

Editing cell with touch

我只是将touchstart触摸事件添加到双击处理程序中 - 当我有时间时,我将创建自己的触摸处理程序,因为双击可能不仅仅是编辑单元格。

代码:

 RenderedCell.prototype.addCellDoubleClickedHandler = function () {
            var that = this;
            var colDef = this.column.colDef;
            this.vGridCell.addEventListener('dblclick', function (event) {
                // always dispatch event to eventService
                var agEvent = that.createEvent(event, this);
                that.eventService.dispatchEvent(grid.Events.EVENT_CELL_DOUBLE_CLICKED, agEvent);
                // check if colDef also wants to handle event
                if (typeof colDef.onCellDoubleClicked === 'function') {
                    colDef.onCellDoubleClicked(agEvent);
                }
                if (!that.gridOptionsWrapper.isSingleClickEdit() && that.isCellEditable()) {
                    that.startEditing();
                }
            });
            //TOUCH HANDLER
            this.vGridCell.addEventListener('touchstart', function (event) {
                // always dispatch event to eventService
                var agEvent = that.createEvent(event, this);
                that.eventService.dispatchEvent(grid.Events.EVENT_CELL_DOUBLE_CLICKED, agEvent);
                // check if colDef also wants to handle event
                if (typeof colDef.onCellDoubleClicked === 'function') {
                    colDef.onCellDoubleClicked(agEvent);
                }
                if (!that.gridOptionsWrapper.isSingleClickEdit() && that.isCellEditable()) {
                    that.startEditing();
                }
            });

        };

我会看一下拖放功能,虽然这对我来说不是那么重要。似乎AG Grids已经为此编写了自己的功能,因此我确信使用可以复制的触摸事件来触摸它。

在iPhone 6上的GOOD浏览器中测试并工作