我正在使用ag-Grid和Node.js在数据库中进行一些更新。我正在对5个字段进行计算。我正在使用onCellValueChanged事件,以便根据field2中的更改对field3field4field5field1进行计算。当发生mouse单击事件时,我可以看到更改。但是,当我按下键盘上的TAB键时,就会出现问题。它给了我这个错误:

ag-grid-community.min.noStyle.js:110 Uncaught TypeError: Cannot read property 'getColSpanningList' of undefined
    at t.getLastCellOfColSpan (ag-grid-community.min.noStyle.js:110)
    at t.findNextCellToFocusOn (ag-grid-community.min.noStyle.js:110)
    at t.moveToNextEditingCell (ag-grid-community.min.noStyle.js:110)
    at t.moveToCellAfter (ag-grid-community.min.noStyle.js:110)
    at t.onTabKeyDown (ag-grid-community.min.noStyle.js:110)
    at t.onTabKeyDown (ag-grid-community.min.noStyle.js:242)
    at t.onKeyDown (ag-grid-community.min.noStyle.js:242)
    at t.processKeyboardEvent (ag-grid-community.min.noStyle.js:530)


这是我的ejs模板:

selection.ejs

var tableCols = <%- JSON.stringify(tables) %>;
var rowData = tableCols;

var columnDefs = [
                  {headerName: "Field1", field: "field1", editable: true},
                  {headerName: "Field2", field: "field2"},
                  {headerName: "Field3", field: "field3"},
                  {headerName: "Field4", field: "field4"},
                  {headerName: "Field5", field: "field5"},
                  {headerName: "Total", field: "total"}
                 ];

var gridOptions = {
             columnDefs: columnDefs,
             rowData: rowData,
             onCellValueChanged: function(params){
                 var d = params.data.field1;
                 var id = params.data.Unique_ID;
                 params.field2  = (.25 * params.data.field1).toFixed(2);
                 var q = params.data.field2;

                    params.data.field3 = (0 * params.data.field1).toFixed(2);
                    var b = params.data.field3;

                    params.data.field4 = (.175 * params.data.field1).toFixed(2);
                    var p = params.data.field4;

                    params.data.field5 = (.20 * params.data.field1).toFixed(2);
                    var a = params.data.field5;

                    params.data.total = (parseFloat(params.data.field1) + parseFloat(params.field2 ) + parseFloat(params.data.field3) + parseFloat(params.data.field4) + parseFloat(params.data.field5)).toFixed(0);
                    var t = params.data.total;

                    this.api.refreshCells();
                  },
                  onCellEditingStarted: function(event){
                        console.log("started");
                      },
                // this is where the error happens, then logs "cellEditingStopped"

                  onCellEditingStopped: function(event) {
                      console.log('cellEditingStopped');
                    }
                };


我不知道如何按TAB键会导致错误,但不能按MOUSE单击。任何帮助,将不胜感激。谢谢。

最佳答案

我可以重现此问题。当您使用editable:false跳至下一列时,将给出错误。如果您评论选项editable:false,则选项卡将正常工作。

我想您可能需要实现自己的tabToNextCell:https://www.ag-grid.com/javascript-grid-keyboard-navigation/#tabtonextcell

我正在弄清楚如何跳过可编辑的:假单元格。

关于node.js - 未捕获的TypeError:无法读取属性getColSpanningList,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56739566/

10-12 19:38