As you might imagine, having to type out the department id by hand is very cumbersome, especially if there are hundreds or even thousands of departments.
Therefore, I want to implement an autocomplete field that does the following things:
When creating a new employee (no id in the URL), I want to be able to search for departments (with pagination/lazy loading) based on their name and store the id of the department inside my EmployeeDetailDto.
When editing an employee, the corresponding department autocomplete has to be prefilled with the employee’s department name. Additionally, the same functionality (paging+search) of the previous bullet point still has to be applied.
Questions
How can one achieve this functionality? It is important for me to only provide the departmentId to my endpoint, the autocomplete with pagination and searching by name is just a help for users to enter the right department id.
Furthermore, is it possible to combine this with AutoCRUD, AutoGrid and AutoForm components?
You could use vaadin-combo-box. You can type text in the field, filter and reload data on change. It also supports a lazy data provider function in frontend.