When saving an entity , the UI doesn't refresh and shows it!

Hi guys ! So lets assume i create a new View and in this view i’m starting to create columns . The first created column is saved in the DB and at the moment is shown in the UI with notification “details stored” but when i try to save a new column when i use grid.getLazyDataView().refreshAll(). it throws an IllegalState exception . I changed it to getGenericDataView().refreshAll(). and the exception is gone but the new column is not shown in the UI until refreshing the page ?

Trying to understand what you want, just to make sure, do you really mean columns, not rows? Those refreshAll methods checks your backend call for new rows(aka items), it has nothing to do with the column definitions. So if you really mean columns, how do you “create” them?

Yes i mean rows . Just the entity is named columns (my bad )

Lets say when i click save on creating new row , the first row is created successfully and is shown immediately in the UI . But on the next row i want to save , the notification that it has been saved is shown , but it doesnt refresh in the UI and it is not shown until refreshing the page !

Sounds like we’d need to debug that (or see the code) to see what is happening there.

Instead of using any of those refreshAll methods via dataviews, I tend to create a method like “listRows” that actually resets the rows, in whatever way you are doing that currently (lazy loading or just passing list of items). Then I’m calling that in when entering the view or if I for some other reasons know that the listing has change (like after a row has been inserted). The refreshRows approach don’t really bring in any performance gains in a typical architecture as Grid can’t cache the rows.

Maybe a code example is better than the lengthy description of the method I consider less error prone: Reset items to grid instead of getting into internals and refreshAll · mstahv/enhancing-master-detail-view@0d17790 · GitHub

the clearAndRefresh method invokes the refreshGrid method

which is throwing the exception

if it is grid.getLazyDataView().refreshAll();

when i changed it to getGenericDataView() it doesnt throw exception but its not refreshing the grid

and not showing the newest added row

and the same abstract logic is used for persisting users and it works for users tho

details: java.lang.IllegalStateException: GridLazyDataView only supports ‘BackEndDataProvider’ or it’s subclasses, but was given a ‘AbstractDataProvider’.
Use either ‘getLazyDataView()’, ‘getListDataView()’ or ‘getGenericDataView()’ according to the used data type… Please check for invalid fields!

thats the exception

Yeah, that’s excatly the issue, dataview depends on the strategy you are using to populate the Grid.

Did you try the approach I suggested? You can use that “DataProvider approach” you are currently using instead of the single lambda lazy loading that is used in my example, if you don’t want to change everything at once.

aiight it worked


i putted the setGridItems() instead of the grid.getGenericDataView()