I encountered this while trying to store a Record in a field in a list grid. I could see the field with getEditedRecord() after inserting it with setEditValue(), but I didn't see it when I called getRecords() after saving.
In this test case, I try a change to a defined field (where the field exists in the datasource) and an undefined field, and neither change appears to be showing up in getRecords(), although the list grid does show changes to the defined field.
I tried it with 2.4, 2.0 snapshot, and the nightly from smartclient.com/builds.
The log shows
when I click the button.
As far as I can tell, this is equivalent to what is discussed at http://forums.smartclient.com/showthread.php?t=1761 , so I assume this should work.
In this test case, I try a change to a defined field (where the field exists in the datasource) and an undefined field, and neither change appears to be showing up in getRecords(), although the list grid does show changes to the defined field.
I tried it with 2.4, 2.0 snapshot, and the nightly from smartclient.com/builds.
Code:
VLayout layout = new VLayout(); final ListGrid grid = new ListGrid(); DataSource gridDS = new DataSource(); gridDS.setClientOnly(true); DataSourceTextField id = new DataSourceTextField("id", "id"); id.setPrimaryKey(true); id.setCanEdit(false); id.setHidden(false); DataSourceTextField a = new DataSourceTextField("a", "a"); a.setCanEdit(true); a.setHidden(false); gridDS.setFields(id, a); DataClass testData[] = new DataClass[5]; for (int currentTestItem = 0; currentTestItem < 5; currentTestItem++) { testData[currentTestItem] = new DataClass(); testData[currentTestItem].setAttribute("id", new Integer(currentTestItem).toString()); testData[currentTestItem].setAttribute("a", "a"); testData[currentTestItem].setAttribute("b", "b"); } gridDS.setTestData(testData); grid.setDataSource(gridDS); grid.setAutoFetchData(true); layout.addMember(grid); IButton button = new IButton("test"); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { grid.setEditValue(1, "a", "A"); grid.setEditValue(1, "b", "B"); grid.saveAllEdits(); for (Record record : grid.getRecords()) GWT.log("Record " + record.getAttribute("id") + " attributes: " + SC.echoAll(record.getJsObj())); } }); layout.addMember(button); layout.draw();
Code:
00:16:05.362 [INFO] Record 0 attributes: {id: "0", a: "a", b: "b"} 00:16:05.364 [INFO] Record 1 attributes: {id: "1", a: "a", b: "b"} 00:16:05.364 [INFO] Record 2 attributes: {id: "2", a: "a", b: "b"} 00:16:05.364 [INFO] Record 3 attributes: {id: "3", a: "a", b: "b"} 00:16:05.365 [INFO] Record 4 attributes: {id: "4", a: "a", b: "b"}
As far as I can tell, this is equivalent to what is discussed at http://forums.smartclient.com/showthread.php?t=1761 , so I assume this should work.
Comment