Entrypoint class:
Data class:
HTML :
I guess that will be considered as ready to run test case. Editing the capital field will open a window and clicking the button on window will reproduce the issue.
I hope this helps in reproducing the issue.
Code:
public class CountryDataDemo implements EntryPoint { protected boolean isTopIntro() { return true; } public class ListGridItem extends CanvasItem { ListGridItem(String name) { super(name); setEndRow(true); setStartRow(true); setColSpan("*"); setShowTitle(false); setInitHandler(new FormItemInitHandler() { @Override public void onInit(FormItem item) { ListGrid grid = new ListGrid(); grid.setWidth(700); grid.setHeight(700); grid.setLeaveScrollbarGap(false); grid.setFields(((ListGridItem) item).getGridFields()); grid.setData(((ListGridItem) item).getGridData()); grid.setAutoFetchData(true); grid.setCanEdit(true); grid.setEditorCustomizer(event -> { if (event.getEditField().getName().equals("capitalId")) { return new CustomTextItem(event, grid); } return event.getDefaultProperties(); }); ((CanvasItem) item).setCanvas(grid); } }); } private ListGridRecord[] gridData; public void setGridData(ListGridRecord[] gridData) { this.gridData = gridData; } public ListGridRecord[] getGridData() { return gridData; } private ListGridField[] gridFields; public void setGridFields(ListGridField... gridFields) { this.gridFields = gridFields; } public ListGridField[] getGridFields() { return gridFields; } }; @Override public void onModuleLoad() { final DynamicForm exampleForm = new DynamicForm(); exampleForm.setLeft(200); exampleForm.setCanDragResize(true); exampleForm.setBorder("3px solid #0083ff"); ListGridItem countryField = new ListGridItem("countryName"); countryField.setGridData(CountrySampleData.getRecords()); ListGridField country = new ListGridField("countryName", "Country"); /* id field with displayField */ ListGridField capital = new ListGridField("capitalId", "Capital"); capital.setDisplayField("capitalDescription"); capital.setValueField("capitalId"); countryField.setGridFields(country, capital); TextItem emailField = new TextItem("Email"); exampleForm.setFields(countryField, emailField); HLayout panel = new HLayout(); panel.setMembers(exampleForm); panel.draw(); } } class CustomTextItem extends TextItem { public CustomTextItem(ListGridEditorContext context, ListGrid grid) { Window popUp = new Window(); popUp.setIsModal(true); popUp.setShowCloseButton(true); popUp.setShowMinimizeButton(false); popUp.setCanDragResize(true); popUp.setCanDrag(true); popUp.setCanDrop(true); popUp.setCanDragReposition(true); popUp.setKeepInParentRect(true); Button button = new Button("Set edit values"); button.setTop(100); button.setLeft(400); button.setWidth("100"); button.setHeight("50"); popUp.addChild(button); button.addClickHandler(event -> { /* I am providing the value of display field as well but it shows ID 19 */ grid.setEditValue(context.getRowNum(), "capitalId", "19"); grid.setEditValue(context.getRowNum(), "capitalDescription", "SomeCapital"); popUp.close(); }); this.setCanEdit(false); addClickHandler(event -> { popUp.setRect(1200, 350, 900, 500); popUp.centerInPage(); popUp.setShowCloseButton(false); popUp.show(); }); setFetchMissingValues(false); setUseLocalDisplayFieldValue(true); } }
Data class:
Code:
public class CountrySampleData { private static ListGridRecord[] records; public static ListGridRecord[] getRecords() { if (records == null) { records = getNewRecords(); } return records; } public static ListGridRecord createRecord(String countryName, int capitalId, String capitalDesc) { ListGridRecord record = new ListGridRecord(); record.setAttribute("countryName", countryName); record.setAttribute("capitalId", capitalId); record.setAttribute("capitalDescription", capitalDesc); return record; } public static ListGridRecord[] getNewRecords() { return new ListGridRecord[] { createRecord("United States", 1, "Washington, DC"), createRecord("China", 2, "Beijing") }; } }
HTML :
Code:
<!doctype html> <!-- The DOCTYPE declaration above will set the --> <!-- browser's rendering engine into --> <!-- "Standards Mode". Replacing this declaration --> <!-- with a "Quirks Mode" doctype is not supported. --> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!-- <meta name="gwt:property" content="locale=de"> --> <!-- --> <!-- Consider inlining CSS to reduce the number of requested files --> <!-- --> <link type="text/css" rel="stylesheet" href="CountryDataDemo.css"> <!-- --> <!-- Any title is fine --> <!-- --> <title>Country Data</title> <!-- --> <!-- This script loads your compiled module. --> <!-- If you add any GWT meta tags, they must --> <!-- be added before this line. --> <!-- --> <script type="text/javascript" language="javascript">var isomorphicDir = "/countrydatademo/sc/"</script> <script type="text/javascript" language="javascript" src="countrydatademo/countrydatademo.nocache.js"></script> <script src="countrydatademo/sc/modules/ISC_Core.js"></script> <script src="countrydatademo/sc/modules/ISC_Foundation.js"></script> <script src="countrydatademo/sc/modules/ISC_Containers.js"></script> <script src="countrydatademo/sc/modules/ISC_Drawing.js"></script> <script src="countrydatademo/sc/modules/ISC_Grids.js"></script> <script src="countrydatademo/sc/modules/ISC_Charts.js"></script> <script src="countrydatademo/sc/modules/ISC_Forms.js"></script> <script src="countrydatademo/sc/modules/ISC_RichTextEditor.js"></script> <script src="countrydatademo/sc/modules/ISC_Calendar.js"></script> <script src="countrydatademo/sc/modules/ISC_DataBinding.js"></script> <script src="countrydatademo/sc/skins/Tahoe/load_skin.js"></script> </head> <body> <script src="countrydatademo/sc/DataSourceLoader?dataSource=countrydatasource"></script> <script src="countrydatademo/sc/DataSourceLoader?dataSource=supplyItem"></script> <!-- RECOMMENDED if your web app will not function without JavaScript enabled --> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> <table align="center"> <tr> <td colspan="2" style="font-weight:bold;"></td> </tr> <tr> <td id="formContainer"></td> <td id="buttonContainer"></td> </tr> <tr> <td colspan="2" style="color:red;" id="errorLabelContainer"></td> </tr> </table> </body> </html>
I guess that will be considered as ready to run test case. Editing the capital field will open a window and clicking the button on window will reproduce the issue.
I hope this helps in reproducing the issue.
Comment