vue.js - (Vue 3)错误: AG Grid: cannot get grid to draw rows when it is in the middle of drawing rows

标签 vue.js vuejs3 drawing ag-grid ag-grid-vue

-- 初始设置--

创建组件

const ButtonAgGrid= {
  template: "<button>{{ displayValue }}</button>",
  setup(props) {
    const displayValue = 'TEST-TEXT';
    return {
      displayValue,
    };
  },
};

注册组件

<AgGridVue
  :components="{
    ButtonAgGrid
  }"
  ...
/>

传递数据

const columnDefs = [
{
  field: "name"
},
{
  field: "button",
  cellRenderer: "ButtonAgGrid",
}
]

const rowData = computed(() => {
  return {
   name: testReactiveValue.value ? 'test', 'test2'
  }
})

当计算出的“rowData”更新时,agGrid 发送错误:

Error: AG Grid: cannot get grid to draw rows when it is in the middle of drawing rows. Your code probably called a grid API method while the grid was in the render stage. To overcome this, put the API call into a timeout, e.g. instead of api.redrawRows(), call setTimeout(function() { api.redrawRows(); }, 0). To see what part of your code that caused the refresh check this stacktrace.

但是如果我们删除cellRenderer: "ButtonAgGrid",一切都会正常工作

最佳答案

我的解决方案是手动更新rowData

watchEffect(() => {
  gridApi.value?.setRowData(props.rowData);
});

这个效果很好,但我希望它是原来的

关于vue.js - (Vue 3)错误: AG Grid: cannot get grid to draw rows when it is in the middle of drawing rows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73700436/

相关文章:

iphone - 在 iOS 上绘制带阴影的矩形

javascript - Vue.js 调用组件/实例方法

javascript - Vue js 在输入字段中对 v-model 应用过滤器

vue.js - 组件中的 $on 监听器可以监听来自 mixin 的 $emit 吗?

vue.js - 如何在 Vue/Nuxt 中使用微前端?

typescript - 如何使用 Typescript 在 Vue 3.0 setup() 函数中使用 async/await

vue.js - 使用 vue-datetime 的 Directus 界面

vue.js - 如何修复 Vue 3 中的 "Error: Unknown option: devServer"

c# - C# 2.0 可以创建发光效果吗?

c++ - 在 C++ 中画一个圆,而是画一个菱形