Table row-headers bind with entity state

Hello,
Is it possible to bind the row header icons with the state of an entity? Like newly created (not yet saved) or edited/dirty (not yet saved), etc? I’m trying to do this with inline/single-screen editing and need a way to visually indicate new and changed rows.

Thanks!

Hi,

Sorry for a long reply. You can use PersistenceHelper.isNew to determine the new state of an entity. For example:


if (PersistenceHelper.isNew(entity)) {
   return "font-icon:PLUS_SQUARE";
}

Unfortunately, we don’t have any public API to determine the modified state of an entity, but you can cast your data source to internal interface DatasourceImplementation and use getItemsToUpdate to find out is an entity modified but not saved yet.


private boolean isEdited(Entity entity) {
   return ((DatasourceImplementation) personsDs).getItemsToUpdate().contains(entity);
}

I’ve prepared demo project at github

Regards,

Gleb

This is great, I will try it out soon and let you know how it goes!