简体   繁体   中英

Vaadin Flow How to control focus TextField in Grid?

As my first question

SerializableFunction<MyItem, TextField> function = item -> {
TextField tf = new TextField();
tf.setValue(item.getMyValue());
tf.addValueChangeListener(e -> item.setMyValue(e.getValue()));
return tf;
};
ComponentRenderer<TextField, MyItem> cr = new ComponentRenderer<>(function); 

I found another problem that I found no way to indicate focus of textField on SelectChange event of Grid.

I found that when add a new record , the SelectChange event is prior to the create of textField.

and seems vaadin has no Row Concept ?

First thought that springs to mind: add a class variable that keeps track of the latest selected item (updated when the selection change listener is triggered), and check your item against that in your function . (And maybe also another class variable for saving the previously styled TextField, so that you can remove the selection styling too.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM