Master->detail form filter rows in detail table interactive

Hi,

On master detail form (orders->orderdetails), on orderdetail edit form (“OrdersEdit”) I have a table with order details.

In OrdersEdit controller I want to make a filter of order rows and didn’t figure out how can be done.
I cannot use the customer data loader customerDl because the details are not saved yet (and calling data loader Load method will bring back from database unsaved data) so I need to filter the data in ordersTable some how interactive.

Thank you.
Camil Ghircoias

Hi Camil,

I’m not sure why you are talking about “customer data loader customerDl”, but from the rest of your problem description I assume that you need to filter data in a CollectionPropertyContainer with OrderDetails that are loaded together with the Order.

In this case, you cannot filter by query indeed, because there is no filter for Details, they are loaded all for the particular Order.

You have to filter the collection in memory and set it to the container using its setDisconnectedItems() method, as shown in the example in the end of the Property Containers section:

@Autowired
private CollectionPropertyContainer<Employee> employeesDc;

private void filterByPosition(Position position) {
    List<Employee> filtered = getEditedEntity().getEmployee().stream()
            .filter(employee -> employee.getPosition().equals(position))
            .collect(Collectors.toList());
    employeesDc.setDisconnectedItems(filtered);
}

private void resetFilter() {
    employeesDc.setDisconnectedItems(getEditedEntity().getEmployee());
}

Regards,
Konstantin

4 Likes

This is what i need. Thanks