All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.vaadin.elements.grid.GridSearchFieldFactory Maven / Gradle / Ivy

/*
 * Copyright (c) 2019 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.vaadin.elements.grid;

import java.util.function.Function;

import io.imunity.vaadin.elements.SearchField;

/**
 * Helps create search field for {@link FilterableGrid}
 * 
 * @author P.Piernik
 *
 */
public class GridSearchFieldFactory
{
	public static SearchField generateSearchField(FilterableGrid grid, Function msg)
	{
		SearchField searchText = new SearchField(msg.apply("search"), searched ->
		{

			grid.clearFilters();
			if (searched == null || searched.isEmpty())
			{
				return;
			}
			grid.addFilter(e -> e.anyFieldContains(searched, msg));
		});
		return searchText;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy