Hello!
I do not know if this is a bug or not: if I change the data in a datasource (using setCacheData in clientOnly dataSource), the components are not refreshed with new data, unless you leave this view and return to him. Should not widgets (listGirds) automatically refresh?
There a testCase example:
if I uncommented this
it will show the second testData in the listGrid. Therefore, the value changes internally on dataSource, but not shown in the listgrid upgrade.
SmartClient Version: SNAPSHOT_v9.1d_2013-07-20/LGPL Development Only (built 2013-07-20)
Browser: Firefox 22.0 in ubuntu 12.04
best regards
I do not know if this is a bug or not: if I change the data in a datasource (using setCacheData in clientOnly dataSource), the components are not refreshed with new data, unless you leave this view and return to him. Should not widgets (listGirds) automatically refresh?
There a testCase example:
Code:
public class ns implements EntryPoint {
private ToolStripButton changeCacheBtn;
private static final int TOOLSTRIP_HEIGHT = 24;
public void onModuleLoad() {
// Data Source
final DataSource dataSource = new DataSource();
dataSource.setID("dataSource");
dataSource.setClientOnly(true);
DataSourceIntegerField id = new DataSourceIntegerField("id", "Id");
id.setPrimaryKey(true);
DataSourceTextField name = new DataSourceTextField("name", "Name");
DataSourceIntegerField value = new DataSourceIntegerField("value", "Valor");
dataSource.setFields(id, name, value);
/*
* First testData
*/
ListGridRecord listGridRecord1 = new ListGridRecord();
listGridRecord1.setAttribute("id", "1");
listGridRecord1.setAttribute("name", "George");
listGridRecord1.setAttribute("value", 5);
ListGridRecord listGridRecord2 = new ListGridRecord();
listGridRecord2.setAttribute("id", "2");
listGridRecord2.setAttribute("name", "Manu");
listGridRecord2.setAttribute("value", 3);
final ListGridRecord[] listGridRecords1 = new ListGridRecord[] { listGridRecord1, listGridRecord2 };
/*
* Second testData
*/
ListGridRecord listGridRecord3 = new ListGridRecord();
listGridRecord3.setAttribute("id", "3");
listGridRecord3.setAttribute("name", "Jack");
listGridRecord3.setAttribute("value", 4);
ListGridRecord listGridRecord4 = new ListGridRecord();
listGridRecord4.setAttribute("id", "4");
listGridRecord4.setAttribute("name", "Shophie");
listGridRecord4.setAttribute("value", 349);
final ListGridRecord[] listGridRecords2 = new ListGridRecord[] { listGridRecord3, listGridRecord4 };
// Add first testData to dataSource
dataSource.setCacheData(listGridRecords1);
// Create a listGrid
final ListGrid listGrid = new ListGrid();
listGrid.setWidth100();
listGrid.setHeight100();
listGrid.setDataSource(dataSource);
listGrid.setAutoFetchData(true);
//dataSource.setCacheData(listGridRecords2);
// Crear ToolStrip
ToolStrip gridEditControls = new ToolStrip();
gridEditControls.setWidth100();
gridEditControls.setHeight(TOOLSTRIP_HEIGHT);
LayoutSpacer spacer = new LayoutSpacer();
spacer.setWidth("*");
changeCacheBtn = new ToolStripButton();
changeCacheBtn.setIcon("[SKIN]/actions/add.png");
changeCacheBtn.setTitle("Change Cache");
// Add ClickHandler
changeCacheBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// chanche data, but doesn't update the listGrid view
dataSource.setCacheData(listGridRecords2);
}
});
// Add members to ToolStrip
gridEditControls.setMembers(spacer, changeCacheBtn);
// Add toolStrip to GRID
listGrid.setGridComponents(new Object[] { ListGridComponent.FILTER_EDITOR, ListGridComponent.HEADER,
ListGridComponent.BODY, gridEditControls });
// Indicate the fields to show
ListGridField idField = new ListGridField("id", "Id");
idField.setHidden(true);
ListGridField nameField = new ListGridField("name", "Name");
nameField.setRequired(true);
ListGridField valueField = new ListGridField("value", "Value");
valueField.setType(ListGridFieldType.INTEGER);
valueField.setRequired(true);
// Add filds to grid
listGrid.setFields(idField, nameField, valueField);
listGrid.draw();
}
}Code:
dataSource.setCacheData(listGridRecords2);SmartClient Version: SNAPSHOT_v9.1d_2013-07-20/LGPL Development Only (built 2013-07-20)
Browser: Firefox 22.0 in ubuntu 12.04
best regards