Environment - Firefox 3.6.13, Smartgwtee 2.4 eval
We are trying to use the DataSource.load(String, Function, boolean) method to dynamically load a datasource. We are trying to do this rather than use the static DataSourceLoader definitions in the startup.html file.
Our onModuleLoad() code is:
The code that we place in our onModuleLoad() is:
Our loadDataSources method is:
If at the time of building the ListGrid, the DataSource is null because it has not been fully dynamically loaded we cannot do grid.setDataSource(ds) and obviously no data is fetched. However our 'custom' ListGridFields are shown in the grid header.
If we subsequently try to 'refresh' the grid (post the completion of the datasource load), the 'custom' ListGridFields are completely ignored and all the fields specified in the datasource.xml file are used. In addition any other 'customizations' such as setShowFilterEditor are also lost!
Is this the expected behavior?
A test case based on the BuiltinDS sample is attached. It has 2 grids. The first uses a statically loaded 'animals' datasource. The second grid uses a dynamically loaded 'animals_2' datasource (which is identical to animals but with the dsId changed to animals_2). Try running the example and observe that the second grid initially shows no data. Then hit the 'Refresh' button on both grids and see what happens.
Finally, if we defer the creation of the ListGrid until we *know* that the dynamically loaded datasource is loaded and is available and allows us to do grid.setDataSource() it all works as intended. But clearly, this cannot be possible in the general case.
Thoughts?
We are trying to use the DataSource.load(String, Function, boolean) method to dynamically load a datasource. We are trying to do this rather than use the static DataSourceLoader definitions in the startup.html file.
Our onModuleLoad() code is:
The code that we place in our onModuleLoad() is:
Code:
public void onModuleLoad() { /* * Try to force the dynamic load a datasource which may * not have been loaded through the .html file */ DataSource ds = DataSource.get("animals_2"); if (ds == null) { loadDataSources("animals_2"); } else { System.err.println("Skipping dyamic load as already loaded"); } Canvas c = createView(); /* build the view which includes a ListGrid */ c.draw(); }
Code:
public void loadDataSources(final String dsName) { DataSource.load(dsName, new com.smartgwt.client.core.Function() { @Override public void execute() { DataSource ds = DataSource.get(dsName); /* try to force it in */ System.err.println("Loaded new DATASOURCES"); } }, true); }
If we subsequently try to 'refresh' the grid (post the completion of the datasource load), the 'custom' ListGridFields are completely ignored and all the fields specified in the datasource.xml file are used. In addition any other 'customizations' such as setShowFilterEditor are also lost!
Is this the expected behavior?
A test case based on the BuiltinDS sample is attached. It has 2 grids. The first uses a statically loaded 'animals' datasource. The second grid uses a dynamically loaded 'animals_2' datasource (which is identical to animals but with the dsId changed to animals_2). Try running the example and observe that the second grid initially shows no data. Then hit the 'Refresh' button on both grids and see what happens.
Finally, if we defer the creation of the ListGrid until we *know* that the dynamically loaded datasource is loaded and is available and allows us to do grid.setDataSource() it all works as intended. But clearly, this cannot be possible in the general case.
Code:
public void loadDataSources(final String dsName) { DataSource.load(dsName, new com.smartgwt.client.core.Function() { @Override public void execute() { DataSource ds = DataSource.get(dsName); /* try to force it in */ System.err.println("Loaded new DATASOURCES"); /* Build the UI now, given the loading success */ Canvas c = createView(); c.draw(); } }, true); }
Comment