DataGrid To Start With Selected Row


How a dataGrid can start with a row selected (the first one) if it is not empty when its screen is loaded?

Thank you in advance.


You should subscribe to AfterShowEvent and check that data is loaded. For instance, for the default entity browse screen:

private CollectionContainer<Order> ordersDc;

private DataGrid<Order> dataGrid;

public void onAfterShow(AfterShowEvent event) {
    Iterator<Order> iterator = ordersDc.getItems().iterator();
    if (iterator.hasNext()) {
1 Like

Thank you Roman.