You are most likely returning "false" as a String rather than a true Boolean false value.
Announcement
Collapse
No announcement yet.
X
-
Hi Isomorphic, thank you.
Yes, I was passing "false" or "true" as String rather than a real boolean value. Is there any way to reload dynamic ds and the related data just after removing a record? I am setting canRemoveRecord to true. So perhaps will be necessary to refresh the grid in order to remove a column just after its related data does not exists anymore. Should be something like an afterRemove event or something like this.
Comment
-
Originally posted by Isomorphic View PostIf your server responds correctly to the remove operation, update of the grid's dataset is automatic. Read about automatic cache synchronization in the QuickStart Guide and in the ResultSet class javadoc.
Yes, when I delete a record, a line from de grid desapear and the related DMI ds method is being invoked, but remember that my ds columns were dynamic generated base on the data, when I delete a record it is possible that some column should not appear anymore (look at for the first doubt posted). If I reload my dynamic ds, this column is not present. However, the grid do not reflect this change. I tried to invoke, .clear(), I tried to .redraw() the grid and nothing happens.
Comment
-
Hi vitor,
please see the note in my post #4
Code:Make sure to have a different Datasource-ID for every different columnList (or always a different Datasource-ID).
If your column list changes (and you want the ListGrid to change as well) you should re-get the .ds.xml definition via DataSource.load(yourDSName). It has a "force" parameter.
You'll most likely have to destroy and recreate the whole ListGrid then.
Note that this only affects the client - the server might show errors if the returned XML is not constant for an DataSource-ID (see above).
Best regards
Blama
Comment
-
Originally posted by Blama View PostYou'll most likely have to destroy and recreate the whole ListGrid then.
I was calling .clear() from the ListGrid, thinking that would resolve. As a matter of fact, did not take any effect. So I did a test right now, following your suggestion above, and the grid disappeared, Below is possible to see how I am instantiating the grid, even I calling this method soon after .destroy() the grid, cannot create it again.
Code:public ListGrid getGrid() { if (grid == null) { grid = new ListGrid(); grid.setTitle(scatext.screen_lunummernkreis_grid()); grid.setWidth100(); grid.setAutoFetchData(false); // grid.setAutoFitFieldWidths(true); // grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH); grid.setAlternateRecordStyles(true); grid.setCanGroupBy(false); grid.setSelectionType(SelectionStyle.SINGLE); grid.setDataFetchMode(FetchMode.BASIC); grid.setShowAllColumns(true); grid.setShowAllRecords(true); grid.setCanRemoveRecords(true); grid.setWarnOnRemoval(true); grid.setWarnOnRemovalMessage(scatext.prompt_grid_onremoval()); grid.setSelectOnEdit(true); grid.setVirtualScrolling(true); this.addMember(grid, 0); } return grid; }
Last edited by vitor.eduardods; 16 Sep 2016, 05:56.
Comment
-
I am overrinding remove from grid by setting setCanRemoveRecords to true and adding a handler for addRemoveRecordClickHandler. This is the code for that:
Code:/** * @return the gridRemoveRecordClickHandler */ public RemoveRecordClickHandler getGridRemoveRecordClickHandler() { if (gridRemoveRecordClickHandler == null) { gridRemoveRecordClickHandler = new RemoveRecordClickHandler() { @Override public void onRemoveRecordClick(RemoveRecordClickEvent event) { final ListGridRecord record = display.getLayout().getGrid().getSelectedRecord(); display.getLayout().getGrid().removeData(record, new DSCallback() { @Override public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) { generateNumberRangesDataSourceDynamycally(); } }); } }; } return gridRemoveRecordClickHandler; }
Code:generateNumberRangesDataSourceDynamycally()
Code:grid.setWarnOnRemoval(true); grid.setWarnOnRemovalMessage(scatext.prompt_grid_onremoval());
What could be the problem?
Comment
-
Thank you Blama about your suggestion regardingCode:add [I]event.cancel()[/I]
- DMI call for generate the dynamic ds:
Code:private void generateNumberRangesDataSourceDynamycally() { String appID = AppServiceConstants.APP_ID; String className = AppServiceConstants.SCAFACADE_SERVICE_NAME; String methodName = AppServiceConstants.METHOD_GETNUMBERRANGES; DMI.call(appID, className, methodName, new PAIRPCCallback() { @Override public void executeRPCCall(RPCResponse response, Object rawData, RPCRequest request) { if (response.getStatus() == RPCResponse.STATUS_FAILURE) { SC.warn( scatext.error_numberrange_datasource_generation() ); } } }, loadNumberRangesDataSource()); }
- Method for load dynamic ds:
Code:private Object[] loadNumberRangesDataSource() { DataSource.load(LUNummernkreiseContent.DYNAMICDS_ID, dataSourceCallbackFunction(), true); return new Object[] { AppController.getRequestToken() }; }
- Function callback for ds loading
Code:private Function dataSourceCallbackFunction() { final Function function = new Function() { @Override public void execute() { dsDynamic = DataSource.get( LUNummernkreiseContent.DYNAMICDS_ID ); if (dsDynamic != null) { setupGrid(); refreshGrid(); } } }; return function; }
- Methods for setting up the grid and refresinh after dynamic ds has been loaded:
Code:protected void setupGrid() { display.getLayout().getGrid().destroy(); // destroying the HTML reference for the component; display.getLayout().setGrid( null ); // nullifying the java object display.getLayout().getGrid().setDataSource( dsDynamic ); final HeaderSpan headerSpan = new HeaderSpan(scatext.screen_lunummernkreis_grid_luHeaderSpan(), new String[] {LUNummernkreiseContent.START_FIELD, LUNummernkreiseContent.END_FIELD}); display.getLayout().getGrid().setHeaderSpans( headerSpan ); display.getLayout().getGrid().getField( LUNummernkreiseContent.START_FIELD ).setTitle( scatext.screen_lunummernkreis_window_spinnerFrom() ); display.getLayout().getGrid().getField( LUNummernkreiseContent.END_FIELD ).setTitle( scatext.screen_lunummernkreis_window_spinnerTo() ); display.getLayout().getGrid().getField( LUNummernkreiseContent.DELIVERYTYPE_FIELD ).setTitle( scatext.screen_lunummernkreis_window_comboType() ); display.getLayout().getGrid().getField( LUNummernkreiseContent.COUNTRYNAME_FIELD ).setTitle( scatext.screen_lunummernkreis_window_comboCountry() ); display.getLayout().getGrid().getField( LUNummernkreiseContent.COUNTRYCODE_FIELD ).setTitle( scatext.screen_lunummernkreis_grid_columnCountryCode() ); } protected void refreshGrid() { display.getLayout().getGrid().fetchData( criteria ); }
Any idea?
Comment
-
Blama, since we have to restart the server in order to have a new descriptor for the same DataSource-ID, my question is: If I implement an DataSource-ID generator toward use a different ID for each server request, what should be the chance that I have performance problems in the future regarding so many unuseful DataSources loaded?
Comment
-
That's one for Isomorphic to answer, but:- The system is implemented this way (prefix, regex) for this very reason, so I suppose it will work
- I'm pretty sure I read somewhere that the actual XML file is cached, so the overhead is only XML processing, no file system IO.
- There is a DataSource pool and you can decide if your dynamic DS are allowed to be in the pool, which might be a bad idea if you have one-time DS in a high frequency, but I don't know that. But this is also doc'd somewhere.
Blama
Comment
Comment