IFilterBarCustomizer
Set of functions you can use to customize some aspects of the FilterBar.
export interface IFilterBarCustomizer
Methods
Method | Description |
|---|---|
Set the rendering mode of the FilterBar. | |
Register a factory for top bar decorator providers. | |
Register a provider for React components to render filter bar. | |
(ALPHA) Register a provider for the component reporting filters the current user is not allowed to see. |
Method details
IFilterBarCustomizer.setRenderingMode()method
Set the rendering mode of the FilterBar.
setRenderingMode(mode: FilterBarRenderingMode): IFilterBarCustomizer;
Parameters
Parameter | Type | Description |
|---|---|---|
mode | the mode to use, see FilterBarRenderingMode for info on individual values |
Returns
IFilterBarCustomizer.withCustomDecorator()method
Register a factory for top bar decorator providers.
withCustomDecorator(providerFactory: (next: FilterBarComponentProvider) => OptionalFilterBarComponentProvider): IFilterBarCustomizer;
Parameters
Parameter | Type | Description |
|---|---|---|
providerFactory | (next: FilterBarComponentProvider) => OptionalFilterBarComponentProvider | factory |
Returns
Remarks
Decorators are a way to add customizations or embellishments on top of an existing component. Decorators are more complex to write because they need to work with the component they should decorate and add ‘something’ on top of that component.
This is best illustrated on an example:
Example
withCustomDecorator((next) => {
return (filter) => {
if (some_condition_to_prevent_decoration) {
return undefined;
}
// Make sure you call this outside the component render function,
// otherwise a new instance of the decorated component is created on each re-render.
const Decorated = next(filter);
function MyCustomDecorator(props) {
return (
<div>
<p>My Custom Decoration</p>
<Decorated {...props} />
</div>
)
}
return MyCustomDecorator;
}
})
The above shows how to register a decorator that will use some condition to determine whether particular attribute filter is eligible for decoration.
Note: the factory function that you specify will be called immediately at the registration time. The provider that it returns will be called at render time.
IFilterBarCustomizer.withCustomProvider()method
Register a provider for React components to render filter bar.
withCustomProvider(provider: OptionalFilterBarComponentProvider): IFilterBarCustomizer;
Parameters
Parameter | Type | Description |
|---|---|---|
provider | provider to register |
Returns
self, for call chaining sakes
Remarks
A provider takes the filter bar as input and is expected to return a React component that should be used to render that filter bar.
If the provider returns undefined then:
- if there are other providers registered, they will be called to see if they can provide a component to render the filter bar - if there are no other providers registered, the default, built-in component will be used.
You may register multiple providers. They will be evaluated in the order you register them.
IFilterBarCustomizer.withRestrictedPlaceholderProvider()methodAlpha
Alpha API. Initial API, highly likely to change outside SemVer. Don’t build on it in production.
Register a provider for the component reporting filters the current user is not allowed to see.
withRestrictedPlaceholderProvider(provider: OptionalRestrictedFiltersPlaceholderComponentProvider): IFilterBarCustomizer;
Parameters
Parameter | Type | Description |
|---|---|---|
provider | provider of the replacement component |
Returns
self, for call chaining
Remarks
The filters are not passed to the provider: only their number reaches the component. Returning undefined keeps the default notice.