Search element in table (filters)

Hi.
could anybody give good examples of using filter in table. I need to do something like quick search for my table. All table datasource is taken from database and I want that search filter works with local data, it mean without any query to database. It is possible?
Build table…

List<XXX> list = xxx.getStaffCards();
qqq= new Table() {
			@Override
			protected String formatPropertyValue(Object rowId, Object colId, Property property) {
				if (property.getType() == Date.class) {
					SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm");
					return df.format((Date) property.getValue());
				}
				return super.formatPropertyValue(rowId, colId, property);
			}
};
some fields for this table...

Insert data to table

for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			QQQ staffCard = (QQQ) iterator.next();
			Item row = zzz.addItem(eee.getId());
			row.getItemProperty("id").setValue(eee.getId());
}

Thank for your advices.

Hi Yury !

You can use filters for any Filterable container, such as BeanItemContainer, HierarchicalContainer, IndexedContainer.
Just set your filter(s) via addContainerFilter method and you’re filtered.

Dmitri

Hi Dmitri!

Can you give some simple examples of using this methods, I will be very grateful.

Hi Yury,

Table table = new Table() ..... 
BeanItemContainer data = new BeanItemContainer();

data.addBean( staffCard1 );
data.addBean( staffCard2 ); 
.....
.....
.....

table.setContainerDatasource(data);


// this will filter to shown only persons, which surname starts with "iva" , like Ivanoff, Ivanov etc...
// "staffSurname" is a name of a field in your StaffCard class
data.addContainerFilter("staffSurname", "iva", true, true); 

P.S. the code above is just a live type to web form, may not compile due to mispells/mistypes

Thanks for your reply Dmitri.
This example really help me to solve filter problem in my application. :grin: