Context: I need to set sorting and filter parameters in an overview. I found the Action OverviewEngineActions.queryParametersChanged but it seems to be descriptive of changes and to not actually change the state of the overview. I already use the selector to be able to read the state of the overview engine OverviewEngineSelectors.getState(activity, overviewModel, documentModel)
How can I set the fieldBasedFilters and sorting of the overviewEnginState ?
Hi Jona,
OverviewEngineActions.queryParametersChanged is the correct action to make changes to fieldBasedFilters and sorting. You could dispatch this action in a component as the following example:
function SomeComponent(props) {
...
const dispatch = useDispatch();
const onClearFilters = () => {
dispatch(OverviewEngineActions.queryParametersChanged({ activityId: props.activityId, fieldBasedFilters: {} }));
};
...
}
Since 2024.06, Overview Engine provides specific actions for sorting and filter changes, including Events.onSorted and Events.onFilterChanged. You could use them as the following example:
function SomeComponent(props) {
...
const dispatch = useDispatch();
const onClearFilters = () => {
dispatch(OverviewEngineActions.event({
activityId,
engineAction: Events.onSorted({
sorting: [{ path: 'product.number', order: 'DESC' }]
})
}));
};
...
}