代码之家  ›  专栏  ›  技术社区  ›  Kelley127

AG Grid从上下文菜单以大文本打开

  •  0
  • Kelley127  · 技术社区  · 2 年前

    使用AG Grid有一种方法可以让单元格使用默认值 agTextCellEditor 编辑器,但可以从上下文菜单中使用 agLargeTextCellEditor ?

    我还没有找到一种方法来动态设置columnDefs来实现这一点。

    尝试使用 startEditingCell 功能没有运气。

    0 回复  |  直到 2 年前
        1
  •  1
  •   Ahmet Firat Keler    2 年前

    我猜你想在它们之间切换。

    基本上,您需要更新列定义。E.x。

    action: () => {
      var columnDefs = gridOptions.api.getColumnDefs()
      columnDefs.forEach(function (colDef, index) {
        if (colDef.colId === 'athlete') {
          colDef.cellEditor = colDef.cellEditor == 'agTextCellEditor' ? 'agLargeTextCellEditor' : 'agTextCellEditor'
        }
      })
      gridOptions.api.setColumnDefs(columnDefs)
    }
    

    为此,您可以在上下文菜单中放置一个项目,并使用上述方法。

    给你。我为你准备了一个塞子。单击切换按钮在agTextCellEditor和agLargeTextCellEditor之间切换。

    https://plnkr.co/edit/xz9WwmS9laL7saO5?preview

    推荐文章