Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AG Grid tooltip takes long time to render

I was following this example and found out that the table takes quite some time to render the tooltip. It doesn't seem to have any delay whatsoever, and I have tried both defaultBrowserTooltip as well as the custom one but both of them are slow. Any given tips on this?

P/S: I'm using React

Some way that I have tried:

tooltipField: 'myTooltipField'

tooltip: (value: string): string => value
like image 837
Tree Nguyen Avatar asked Apr 23 '19 06:04

Tree Nguyen


People also ask

How do you show tooltip on Ag grid?

Default Browser Tooltip If you don't want to use the grid's tooltip component, you can use the enableBrowserTooltips config to use the browser's default tooltip. The grid will simply set an element's title attribute to display the tooltip.

How do I use the tooltip field in Ag grid?

When we want to display a header tooltip, we set the headerTooltip config as a string , and that string will be displayed as the tooltip. However, when working with custom tooltips we set colDef. tooltipComponent to assign the column's tooltip component and the headerTooltip value will passed to the params object.

How do I add a tooltip to Ag grid react?

Example: Using Browser Tooltips 'use strict'; import React, { useCallback, useMemo, useRef, useState } from 'react'; import { render } from 'react-dom'; import { AgGridReact } from 'ag-grid-react'; import 'ag-grid-community/dist/styles/ag-grid. css'; import 'ag-grid-community/dist/styles/ag-theme-alpine.


2 Answers

As of Ag-grid 23.0.0, this is configurable by the tooltipShowDelay configuration option.

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

For earlier versions, Ag-grid used an internal service called TooltipManager which was not configurable.
The default delay was 2 seconds:

private readonly MOUSEOVER_SHOW_TOOLTIP_TIMEOUT = 2000;

For these earlier versions, you could manually get the service reference from the bean bag and override it, but for versions 23.0.0 and up this is not necessary.

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);
    }
}
like image 136
Etheryte Avatar answered Oct 08 '22 08:10

Etheryte


This is directly "borrowed" from user demostheneslld who commented on the ag-grid GitHub feature request, but you can set enableBrowserTooltips: true on the grid options object and then the tooltips will be displayed natively by the browser, rather than formatted by ag-grid. The tooltips then appear almost instantly.

like image 31
S. Baggy Avatar answered Oct 08 '22 09:10

S. Baggy