ExcludeItem Datasource

I have a Table with datasource with vehicles. I want to remove the vehicles which has the same date and time. I have sett up an example like this.


for (Vehicle vehicle : vehiclesDs.getItems()) {
    for(Assignment assignment1 : vehicle.getAssignment()){
        if(assignment1.getAssignmentClosed() == false) {
            Date startDate = assignmentStartDateField.getValue();
            Date endDate = assignmentEndDateField.getValue();

            if (assignment1.getAssignmentStartDate().compareTo(startDate) == 0) {
                if (assignment1.getAssignmentEndDate().compareTo(endDate) == 0) {
                    vehiclesDs.excludeItem(vehicle);
                }
            }
        }
    }
}

vehiclesDs.refresh();
vehiclesTable.repaint();

When I repaint the table the same data is shown. Non is removed in table but is removed in the datasource.

In order to remove an entity instance from the UI table and from the database you need to invoke the removeItem() method of the collection datasource and then commit the whole DsContext or this particular datasource by invoking its commit() method.