Hilla Endpoint with custom headers (e.g. for file download)

You could observe the last used filter by implementing a custom service that extends from the service that you’re currently using in AutoGrid, and then override the list function to store the filter somewhere. For example, assuming you have an OrderService you could do this:

import {OrderService} from 'Frontend/generated/endpoints';
import Pageable from "Frontend/generated/com/vaadin/hilla/mappedtypes/Pageable";
import Filter from "Frontend/generated/com/vaadin/hilla/crud/filter/Filter";
import {EndpointRequestInit} from "@vaadin/hilla-frontend/Connect.js";

const ObservableOrderService = {
    ...OrderService,
    list(pageable: Pageable, filter: Filter | undefined, init?: EndpointRequestInit) {
        console.log('list', pageable, filter, init);
        return OrderService.list(pageable, filter, init);
    },
}

<AutoGrid service={ObservableOrderService} />
3 Likes