Footers
In the GridOptions interface, the below properties are available to customize the footer.
- enableFooters
- footerRowHeight
In the ColumnOptions interface, the below properties are available to customize the footer.
- footerOptions
Below is the list of properties available in the HeaderOptions interface.
export interface FooterOptions {
footerOperation?: FooterOperation;
footerOperationPrecision?: number;
footerLabel?: string;
footerLabelFunction?: (
column: ColumnOptions,
dataProvider: unknown[] | undefined
) => string;
footerRenderer?: (
props: RendererProps
) => unknown;
}
The documentation for the above properties can be found here
Adding a footer
Similar to the header, the footer can be added by setting the enableFooters property to true in the GridOptions interface. Once you set the enableFooters property to true, the footer will be displayed for all the columns. The footer will be displayed at the bottom of the grid by default.
Now that we have enabled the footers, let's customize the footer for each column.
Customizing the footer
The footer can be customized by setting the footerOptions property in the ColumnOptions interface. The footerOptions property is of type FooterOptions. The documentation for the FooterOptions interface can be found here
Let's customize the footer for the annualSalary column. We will set the footerOperation property to "avg" and the footerLabel property to "Avg: ". The footerOperation property can be set to "sum", "avg", "min", "max" or "count". The footerLabel property can be set to a string or a function. If the footerLabel property is set to a function, the function will be called with the column and the dataProvider as arguments. The function should return a string.
Let's customize the footer for the remaining columns, let's set Id to sum, Territory to count, First Name to min, Last Name to max, Hire Date to max, and Salary to sum.
Using the footerLabelFunction property
The footerLabelFunction property can be set to a function. The function will be called with the column and the dataProvider as arguments. The function should return a string.
Let's set the footerLabelFunction property for the annualSalary column. The footerLabelFunction property will return the string " Median: {MedianValue}".
Now that you are familiar with footerLabel and footerLabelFunction, let's take a look at the footerRenderer property.
Using the footerRenderer property
The footerRenderer property can be set to a function. The function will be called with the column and the dataProvider as arguments. The function should return a ReactNode.
Let's set the footerRenderer property for the annualSalary column. The footerRenderer property will return the string " Median: {MedianValue}".
There are additional examples of using the footerRenderer property in the Footer Options example.