I need to be able to hide or delete a row from the table I see on the screen.
I want a row that meets a certain condition to be erased (or hidden). The code is this, but it does not work.
public void eliminarEstados (){
Iterator<?> i = table.getContainerDataSource().getItemIds().iterator();
Item item;
while (i.hasNext()) {
Object key = i.next();
item= table.getContainerDataSource().getItem(key);
Object value = item.getItemProperty("status").getValue();
if (value.equals(1)){
//table.
table.getContainerDataSource().removeItem(item);
}
}
}
If you just need to hide rows not meeting certain criteria, I would recommend to use Filter for that purpose. There is addContainerFilter method you can use if your data source implements Container.Filterable.
The problem I have with filter, is that the column I want to filter from the table is a label that is generated automatically. Because just that column status depends on another connected system. That is, the column I do not have it in my system is forms of class or table in database. That’s why when I apply the filter, it does not find anything. I should be able to search through that label.
Any ideas
Thanks.
I see, yes that is correct, you cannot filter generated columns. I would solve this using another approach. Instead of generated columns I would use DTO instead. I.e. I would create DTO bean, where I have this added property plus the properties I read from the database. Then I will not use the database bean in Table’s container, but this DTO. That way I get this custom property in container and I can filter it normally.
Could you show me an example of using a discount? Because I do not know it. Do I have to change many things to how I have it implemented?
The same filters work.
AddAtribute (“”) …