Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Message over table when empty

Oliv Mor
10 years ago Feb 10, 2012 2:42pm
Oliv Mor
10 years ago Feb 17, 2012 2:22pm

Hi,

Well I've slightly improved to code, using filter features instead of create a new container...

public Example() {

table = new Table();
...
// The search textfield
filterBepTF = new TextField();
filterBepTF.addListener((TextChangeListener) this);

}

public void textChange(TextChangeEvent event)
	{
		Filterable f = (Filterable) table.getContainerDataSource();
		f.removeAllContainerFilters();

		String searchString = event.getText();
		if (searchString != null && searchString.trim().length() != 0)
		{
			AbstractJunctionFilter filter = null;
			for (String part : searchString.trim().split(" "))
			{
				if (filter != null)
					filter = new And(filter, new Or(new SimpleStringFilter(BrowserTable.PROPERTY_NAME, part, true, false), new SimpleStringFilter(
							BrowserTable.PROPERTY_KIND, part, true, false)));
				else
					filter = new Or(new SimpleStringFilter(BrowserTable.PROPERTY_NAME, part, true, false), new SimpleStringFilter(BrowserTable.PROPERTY_KIND,
							part, true, false));
			}

			f.addContainerFilter(filter);
		}

		if (table.getItemIds().isEmpty())
		{
			table.setStyleName("empty");
		}
		else
		{
			table.removeStyleName("empty");
		}

	}

And the style.css:

.v-table-empty .v-table-body {
	background-image: url('no_result.png');
	background-repeat: no-repeat;
	background-position: center center;
}

Any feedback would be appreciate....

Last updated on Feb, 17th 2012
Mathias Clerc
10 years ago Feb 20, 2012 4:29am
mrunal lohar
6 years ago Sep 06, 2015 4:11pm
Adam Jilling
5 years ago Jul 18, 2016 6:22pm
Nikolay Artamonov
5 years ago Apr 12, 2017 12:34pm