Directory

← Back

GridUtil

Toolkit to simplify the use of the grid and adds missing features

Author

Rating

Popularity

100+

This toolkil simplify the use of the grid and adds missing features

  • introduce a easy way to build a filterrow
  • add renderers that allows to display a combination of button and value within one cell (missing view/edit/delete button)
  • shorten the lines of code for writing StringConverter
  • add missing css-settings for cell alignment

The GridCellFilter-Component contains filters for the following types:

  • String
  • Date
  • Number (checks if Integer, Long, Double...)
  • Objects / Enums (via ComboBox with Equals-Filter)
  • allows to add custom Filters and Components

For detailed code-example please take a look in the github demo-application. There I've tried to structure my code so that you can understand the usage and the features...

Sample code

package org.vaadin.gridutil.demo;

import java.text.DateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;

import javax.servlet.annotation.WebServlet;

import org.vaadin.gridutil.GridUtil;
import org.vaadin.gridutil.cell.*;
import org.vaadin.gridutil.converter.SimpleStringConverter;
import org.vaadin.gridutil.demo.data.*;
import org.vaadin.gridutil.renderer.*;
import org.vaadin.gridutil.renderer.EditDeleteButtonValueRenderer.EditDeleteButtonClickListener;

import com.vaadin.*;

@Theme("valo")
public class DemoUI extends UI {

	private GridCellFilter filter;

	@Override
	protected void init(final VaadinRequest request) {
		Grid grid = genGrid();
		
		this.filter = new GridCellFilter(grid);
		this.filter.setNumberFilter("id");

		// set gender Combo with custom icons
		ComboBox genderCombo = this.filter.setComboBoxFilter("gender", Arrays.asList(Gender.MALE, Gender.FEMALE));
		genderCombo.setItemIcon(Gender.MALE, FontAwesome.MALE);
		genderCombo.setItemIcon(Gender.FEMALE, FontAwesome.FEMALE);

		// simple filters
		this.filter.setTextFilter("name", true, true);
		this.filter.setNumberFilter("bodySize");
		this.filter.setDateFilter("birthday");
		this.filter.setBooleanFilter("onFacebook");

		// set country combo with custom caption
		ComboBox countryCombo = this.filter.setComboBoxFilter("country", DummyDataGen.COUNTRIES);
		countryCombo.setItemCaptionMode(ItemCaptionMode.PROPERTY);
		countryCombo.setItemCaptionPropertyId("name");

		setContent(grid);
	}
}
package org.vaadin.gridutil.demo;

import java.text.DateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;

import javax.servlet.annotation.WebServlet;

import org.vaadin.gridutil.GridUtil;
import org.vaadin.gridutil.cell.*;
import org.vaadin.gridutil.converter.SimpleStringConverter;
import org.vaadin.gridutil.demo.data.*;
import org.vaadin.gridutil.renderer.*;
import org.vaadin.gridutil.renderer.EditDeleteButtonValueRenderer.EditDeleteButtonClickListener;

import com.vaadin.*;

@Theme("valo")
public class DemoUI extends UI {

	private GridCellFilter filter;

	@Override
	protected void init(final VaadinRequest request) {
		Grid grid = genGrid();
		
		grid.getColumn("id")
			.setRenderer(new EditDeleteButtonValueRenderer(new EditDeleteButtonClickListener() {
	
				@Override
				public void onEdit(final RendererClickEvent event) {
					Notification.show(event.getItemId()
							.toString() + " want's to get edited", Type.HUMANIZED_MESSAGE);
				}
	
				@Override
				public void onDelete(final com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent event) {
					Notification.show(event.getItemId()
							.toString() + " want's to get delete", Type.WARNING_MESSAGE);
				};
	
			}))
			.setWidth(150);
		grid.getColumn("bodySize")
				.setWidth(150);
		grid.getColumn("birthday")
				.setRenderer(new DateRenderer(DateFormat.getDateInstance()))
				.setWidth(210);
		grid.getColumn("onFacebook")
				.setRenderer(new BooleanRenderer())
				.setWidth(130);

		setContent(grid);
	}
}
package org.vaadin.gridutil.demo;

import java.text.DateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;

import javax.servlet.annotation.WebServlet;

import org.vaadin.gridutil.GridUtil;
import org.vaadin.gridutil.cell.*;
import org.vaadin.gridutil.converter.SimpleStringConverter;
import org.vaadin.gridutil.demo.data.*;
import org.vaadin.gridutil.renderer.*;
import org.vaadin.gridutil.renderer.EditDeleteButtonValueRenderer.EditDeleteButtonClickListener;

import com.vaadin.*;

@Theme("valo")
public class DemoUI extends UI {

	private GridCellFilter filter;

	@Override
	protected void init(final VaadinRequest request) {
		Grid grid = genGrid();
		
		grid.getColumn("country")
				.setConverter(new SimpleStringConverter<Country>(Country.class) {
		
					@Override
					public String convertToPresentation(final Country value, final Class<? extends String> targetType, final Locale locale)
							throws com.vaadin.data.util.converter.Converter.ConversionException {
						return String.format("%s <i>(%d)</i>", value.getName(), value.getPopulation());
					}
				});

		setContent(grid);
	}
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

  • support getValueProvider thx to @oguzakp
  • GridCellFilter without beanType thx to @Flamenco
Released
2018-03-07
Maturity
EXPERIMENTAL
License
MIT License

Compatibility

Framework
Vaadin 8.1+
Vaadin 7.4+ in 1.0.0
Browser
Browser Independent

GridUtil - Vaadin Add-on Directory

Toolkit to simplify the use of the grid and adds missing features GridUtil - Vaadin Add-on Directory
This toolkil simplify the use of the grid and adds missing features - introduce a easy way to build a filterrow - add renderers that allows to display a combination of button and value within one cell (missing view/edit/delete button) - shorten the lines of code for writing StringConverter - add missing css-settings for cell alignment The GridCellFilter-Component contains filters for the following types: - String - Date - Number (checks if Integer, Long, Double...) - Objects / Enums (via ComboBox with Equals-Filter) - allows to add custom Filters and Components For detailed code-example please take a look in the github demo-application. There I've tried to structure my code so that you can understand the usage and the features...
Online