Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add better API to configure maximum allowed rows #12466

Merged
merged 3 commits into from Nov 3, 2021

Conversation

TatuLund
Copy link
Contributor

@TatuLund TatuLund commented Nov 2, 2021

Some components are harder to extend than Grid for overriding max rows limit. However getDataCommunicator is a public method and thus this API would make overriding the limit easier, see example

@Theme("mytheme")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
        
        TwinColSelect<String> twin = new TwinColSelect<>();
        twin.getDataCommunicator().setMaximumAllowedRows(1000);

        ComboBox<String> combo = new ComboBox<>();
        combo.getDataCommunicator().setMaximumAllowedRows(1000);
        
        List<String> items = new ArrayList<>();
        for (int i=0;i<800;i++) {
        	items.add("Item "+i);
        }
        
        twin.setItems(items);
        twin.setItemCaptionGenerator(item -> item.toUpperCase());
        combo.setItems(items);
        combo.setScrollToSelectedItem(true);
        
        layout.addComponents(twin, combo);
        
        setContent(layout);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

@TatuLund TatuLund merged commit b62869b into master Nov 3, 2021
@Ansku Ansku deleted the max-allowed-rows branch November 3, 2021 15:09
Ansku pushed a commit that referenced this pull request Nov 3, 2021
Co-authored-by: Olli Tietäväinen <ollit@vaadin.com>
Ansku pushed a commit that referenced this pull request Nov 3, 2021
Co-authored-by: Olli Tietäväinen <ollit@vaadin.com>
TatuLund added a commit that referenced this pull request Nov 4, 2021
Co-authored-by: Olli Tietäväinen <ollit@vaadin.com>

Co-authored-by: Tatu Lund <tatu@vaadin.com>
Co-authored-by: Olli Tietäväinen <ollit@vaadin.com>
@TatuLund TatuLund added this to the 8.14.3 milestone Nov 11, 2021
@TatuLund
Copy link
Contributor Author

TatuLund commented Nov 24, 2021

Just noting, that Tree does not have convenience API for getting data communicator of the internal TreeGrid, but it is possible to extend Tree as follows:

	public class ExtTree<T> extends Tree<T> {

		public HierarchicalDataCommunicator<T> getDataCommunicator() {
			return ((TreeGrid) super.getCompositionRoot()).getDataCommunicator();
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants