I would like to use a cellRenderer in React for most of my columns. So, in my colDefs, I have an additional field called unit. If the unit exists, I am trying to have a heatMap like color grid which is handled in my TableCell React component. This identical react component has worked in other data grids like ZippyUI. Can the cellRenderer function return a React component, which is a virtual DOM object, or does it have to be a true HTML DOM object? Would doing something like this with ag-Grid's cellRenderer component method be preferable?
colDefs.map((x) => {
if (x.hasOwnProperty('unit')) {
x.cellRenderer = (params) => {
return <TableCell value={params.value} units={x.unit} min={min[x.field]} max={max[x.field]} colorScheme={colorScheme} />;
};
}
});
when you pass the column definition to the ag-grid instance, it will have your function bound to cellrenderer attribute for that column. So when in its build lifecycle it checks the value at cellRenderer it will see your function and fire it then.
The quickest way to achieve a responsive grid is to set the grid's containing div to a percentage. With this simple change the grid will automatically resize based on the div size and columns that can't fit in the viewport will simply be hidden and available to the right via the scrollbar.
agInit() is called once (with the corresponding cell's parameters supplied). The component's GUI will be inserted into the grid 0 or 1 times (the component could get destroyed first, i.e. when scrolling quickly). refresh() is called 0...n times (i.e. it may never be called, or called multiple times).
For React, instead of using cellRenderer
, cellEditor
, etc, you want to use cellRendererFramework
, cellEditorFramework
and pass in a class that has setUp
and render
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With