Vue Data GridStatus Bar Panel
Enterprise
The Status Bar Panel allows you to add your own components to the grid's Status Bar. Use this when the provided status bar components do not meet your requirements.
Implementing a Status Bar Panel Component
Any valid Vue component can be a status bar component, however it is also possible to implement the following optional methods:
interface IStatusPanel {
// Called when the `statusBar` grid option is updated.
// If this method returns `true`, the grid assumes that
// the status panel has updated with the latest params,
// and takes no further action. If this method returns `false`,
// or is not implemented, the grid will destroy and
// recreate the status panel.
refresh(params: IStatusPanelParams): boolean;
// Gets called when the grid is destroyed.
// If your status bar components needs to do any cleanup, do it here.
destroy(): void;
}
When a custom status bar component is instantiated then the following will be made available on this.params.
Properties available on the IStatusPanelParams<TData = any, TContext = any> interface.
apiTypeGridApi | The grid api. |
contextTypeTContext | Application context as set on gridOptions.context. |
Configuring Status Bar Panels
In order to add new components to the Status Bar (or to configure the provided agAggregationComponent component) you need to provide the components and any associated information to statusBar:
this.gridOptions = {
statusBar: {
statusPanels: [
{
statusPanel: 'myStatusBarComponent'
},
{
statusPanel: 'agAggregationComponent',
statusPanelParams : {
// only show count and sum ('min', 'max', 'avg' won't be shown)
aggFuncs: ['count', 'sum']
}
}
]
},
// ...other properties
}
In the configuration above we've specified a custom component (myStatusBarComponent) as well as the provided agAggregationComponent component.
Order is important here - the order of the components provided will determine the order in which they're rendered, from left to right.
Initialisation of Status Bar Components
The status bar components will be instantiated before the grid is fully initialised - specifically they will be initialised before any row data has been rendered.
If you have a component that you wish to work on data once it's ready (calculate the sum of a column for example) then you'll
need to hook into the modelUpdated event. Remember to remove the event listener when the component is destroyed.
export default {
methods: {
updateStatusBar() { ... },
},
created() {
// Remember to remove the event listener when the component is destroyed
this.params.api.addEventListener(
'modelUpdated',
this.updateStatusBar.bind(this)
);
},
};
Accessing Status Bar Panel Instances
After the grid has created an instance of a status bar component it is possible to access that instance. This is useful if you want to call a method that you provide on the status bar component that has nothing to do with the operation of the grid. Accessing a status bar component is done using the grid API getStatusPanel(key).
The example below shows using getStatusPanel: