I am using Vaadin 8.5.1 Grid to display 1000's of rows.
Once a row is updated with change in it property, I use
grid.getDataProvider().refreshItem(selectedRow)
or
grid.getDataProvider().refreshAll()
which fails to update the row.
I need to do explicit grid.setItems()
to see the updated property of the row.
I am using below snippet to create a Grid
msgGrid = new ABSMsgGrid();
List<ConsoleEntry> messageEntryList = new ArrayList<>();
if (inputConsole != null) {
messageEntryList.addAll(inputConsole.getMessageEntryList());
}
msgGridDataProvider = new ListDataProvider<ConsoleEntry>(messageEntryList) {
@Override
public Object getId(ConsoleEntry item) {
return item.getId();
}
};
msgGrid.setDataProvider(msgGridDataProvider);
//on changing property of the grid row, i use the below snippet
private void handleHideRowMenuItem(GridContextMenu<ConsoleEntry> contextMenu, ConsoleEntry selectedConsoleItem) {
if (!selectedConsoleItem.isHidden()) {
hideRowMenuItem = contextMenu.addItem("Hide Row", VaadinIcons.EYE_SLASH, selectedMenuItem -> {
selectedConsoleItem.hide();
**msgGridDataProvider.refreshItem(selectedConsoleItem);**
}
});
}
}
public class ConsoleEntry {
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if (obj instanceof ConsoleEntry) {
ConsoleEntry temp = (ConsoleEntry) obj;
String msgRef2 = temp.getMsgRef();
return this.getMsgRef().equalsIgnoreCase(msgRef2);
}
return false;
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return super.hashCode();
}
public String getId(){
return this.getMsgRef();
}
}
I have seen similar question but none of the solutions worked.
How to refresh the vaadin Grid after you change something?
Vaadin - Refresh grid after row modification
Appreciate if any one could share pointers on how to solve this problem
TIA
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…