AG 网格工具提示需要很长时间才能呈现

AG Grid tooltip takes long time to render

我一直在关注 this example,发现 table 需要相当长的时间来呈现工具提示。它似乎没有任何延迟,我已经尝试了 defaultBrowserTooltip 和自定义的,但它们都很慢。对此有什么建议吗?

P/S:我正在使用 React

我尝试过的一些方法:

tooltipField: 'myTooltipField'

tooltip: (value: string): string => value

从 Ag-grid 23.0.0 开始,这可以通过 tooltipShowDelay configuration option.

配置
const gridOptions = {
  tooltipShowDelay: 0; // milliseconds, default value 2000ms
};

对于早期版本,Ag-grid 使用名为 TooltipManager 的内部服务 not configurable
默认延迟为 2 秒:

private readonly MOUSEOVER_SHOW_TOOLTIP_TIMEOUT = 2000;

对于这些早期版本,您可以手动从豆袋中获取服务引用并覆盖它,但对于 23.0.0 及更高版本,这不是必需的。

private onGridReady(params: GridReadyEvent) {
    // NB! This is unsupported and may break at any time
    try {
      (params.api as any).context.beanWrappers.tooltipManager.beanInstance.MOUSEOVER_SHOW_TOOLTIP_TIMEOUT = 0;
    } catch (e) {
      console.error(e);
    }
}

这直接"borrowed" 来自对 ag-grid GitHub feature request 发表评论的用户 demostheneslld,但您可以在网格选项对象上设置 enableBrowserTooltips: true,然后将显示工具提示本机由浏览器,而不是由 ag-grid 格式化。然后工具提示几乎立即出现。

现在有一个名为 tooltipShowDelay 的 属性,它包含在 2020 年 3 月 17 日发布的版本 23.0.0 中。文档 https://www.ag-grid.com/javascript-grid-properties/#miscellaneous and changelog https://www.ag-grid.com/ag-grid-changelog/?fixVersion=23.0.0

现在发布了一个新道具:

tooltipShowDelay={0}

以上代码将立即显示工具提示。 More Info