0

When using Vaadin 22 the method this.customerGrid.setItems(result.getResult()); selected items of the grid where automatically unselcted and it was not necessary to manually call a method to unselect any itmes. With Vaadin 23 this dies not work anymore, you have to call the method customerGrid.deselectAll();, otherwise The "old" selected items are still present.

This is a big change and therefore I want to ask, if I am doing soething wrong. This is an example code to better illustrate my problem:

// This is how I put items tot the grid
 @Override
    public void updateComponent() {
        try {

            //
            // Populate the grid
            //
            //OrganizationCustomerLazyDataResult result = applicationService.getOrganizationCustomers(membershipGroupSearchField.getMembershipGroup(), membershipGroupSearchField.getValue(), 0, 1000000);
            OrganizationCustomerLazyDataResult result = applicationService.getOrganizationCustomers(filter.getTextSearch(), filter.getOrganizationCustomerGender(), filter.getOrganizationCustomerGroup(), filter.getDateOfBirthFrom(), filter.getDateOfBirthTo(), filter.getEntryDateFrom(), filter.getEntryDateTo(), filter.getMembershipGroup(), filter.isDisplayOrganizationCustomersWithoutContract(), 0, 1000000);
            this.customerGrid.setItems(result.getResult());

            //
            // Set the count label
            //
            count.setText(COUNT_LABEL+" "+result.getCount());
        } catch (UserHasNotEnoughRightsForThisOperationException e) {
            notEnoughRights.open();
        }
    }

// This is a code how I get the selected items of the grid tp proceed with it.
// Unfortunatley the method I call requires an array list and not a Set
MenuItem actions = menu.addItem("Aktionen");
        actions.getSubMenu().addItem("Zu Tarifgruppe hinzufügen", event -> {
            Set<OrganizationCustomer> select = customerGrid.getSelectedItems();
            customerGrid.deselectAll(); // New, was not necessary in Vaadin 22 to deselect
            if(select.size() > 0) {
                ArrayList<OrganizationCustomer> selectList = new ArrayList();
                selectList.addAll(select);
                AddCustomersToMembershipGroupDialog dialog = new AddCustomersToMembershipGroupDialog(applicationService, selectList, this); // This class calls finally the method updateComponent() to reload the grid with possible changes
                dialog.open();
            }
        });

I just want to ensure that I do it the right way, before changing multiple classes containing grid.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Florian
  • 110
  • 7

0 Answers0