AG Grid 在上下文菜单中以大文本形式打开

huangapple go评论187阅读模式
英文:

AG Grid open in large text from context menu

问题

没有找到一种方法可以在使用默认的agTextCellEditor编辑器的情况下,通过上下文菜单来使用agLargeTextCellEditor编辑单元格。我尝试过使用startEditingCell函数,但没有成功。

英文:

Using AG Grid is there a way to have a cell use the default agTextCellEditor editor but from the context menu be able to edit the cell with a agLargeTextCellEditor?

I haven't been able to figure out a way to set the columnDefs on the fly to accomplish this.

Trying to use the startEditingCell function with no luck.

答案1

得分: 1

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

基本上,你需要更新列定义。例如:

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)
}

你可以在上下文菜单中添加一个项目来执行此操作,并使用上面的方法。

在这里。我已经为你准备好了一个 plunker。单击切换以在 agTextCellEditor 和 agLargeTextCellEditor 之间切换。

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

英文:

I guess you wanna toggle between them.

Basically, you need to update column definitions. 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)
}

You may put an item in your context menu for this purpose and use the method above.

Here you are. I've got a plunker ready for you. Click on toggle to toggle between agTextCellEditor and agLargeTextCellEditor.

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

huangapple
  • 本文由 发表于 2023年8月11日 05:21:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76879368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定