When adding record in dataGrid be in the first line and not in the last one

It’s possible that when adding a new record in a dataGrid and it occupies the available screen, do not add it at the end, but do it in the first record of the grid.

image

Hi,

Sure, it’s possible. To do so, you need to cast your datasource to CollectionDatasource.Ordered, for instance:

@Inject
private CollectionDatasource.Ordered<Customer, UUID> customersDs;

and use the addItemFirst method:

Customer customer = metadata.create(Customer.class);
customersDs.addItemFirst(customer);
customersDataGrid.edit(customer);

Regards,
Gleb