We are trying to have a refresh button on a layout that would refresh all the the SelectItems/drop downs on a form as well as a listgrid on the layout. We are OK with refreshing the form SelectItems but not clear on how to do this for SelectItems used as editors in the ListGrid. Searching through the forums, we found the following topic:
http://forums.smartclient.com/showthread.php?t=16506
Which indicated that using DataSource.updateCaches() was the way to deal with stale data due to concurrent updates. Weren't totally clear on how to code this and this was our attempt (accountEditor is the SelectItem we attached to the ListGridField via .setEditorType:
By turning up ResultSet logging, we see indications that the updateCache is working but am not seeing this reflected in the drop-down.
15:00:17.591:INFO:ResultSet:isc_PickListMenu_1:Creating new isc.ResultSet for operation 'ActivityAccountMapDS_fetch' with filterValues: {
"activityId":"28"
}
...
15:00:18.226:XRP7:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Received 2 records from server
15:00:18.230:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):full length set to: 2
15:00:18.254:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):integrating 2 rows into cache at position 0
...
15:00:18.264:XRP7:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Cache for current criteria complete
15:00:18.274:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):getRange(0, 1) satisfied from cache
...
Add record to table outside of SmartGWT
...
15:02:19.048:XRP4:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):dataSource data changed firing
15:02:19.067:XRP4:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):updating cache in place after operationType: undefined, allMatchingRowsCached true
15:02:19.086:XRP4:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Updating cache: operationType 'undefined' (no componentID) ,3 rows update data:
...
But SelectItem still only shows the first 2 items
...
15:02:22.436:TMR5:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):setCriteria: filter criteria unchanged
15:02:22.440:TMR5:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):getRange(0, 1) satisfied from cache
...
Think we may be missing something in our usage of DataSource.updateCaches() and/or how to force the SelectItem to render the new cache rows and wanted to check that with others before diagnosing further. Let me know if you need more from me on this.
Ed Reddy
http://forums.smartclient.com/showthread.php?t=16506
Which indicated that using DataSource.updateCaches() was the way to deal with stale data due to concurrent updates. Weren't totally clear on how to code this and this was our attempt (accountEditor is the SelectItem we attached to the ListGridField via .setEditorType:
Code:
if (accountEditor != null && accountEditor.getOptionDataSource() != null) { final DataSource ds = accountEditor.getOptionDataSource(); ds.fetchData(accountEditor.getOptionCriteria(), new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { if (response.getStatus() == DSResponse.STATUS_SUCCESS) { int size = response.getTotalRows(); ds.updateCaches(response); } } }); }
15:00:17.591:INFO:ResultSet:isc_PickListMenu_1:Creating new isc.ResultSet for operation 'ActivityAccountMapDS_fetch' with filterValues: {
"activityId":"28"
}
...
15:00:18.226:XRP7:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Received 2 records from server
15:00:18.230:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):full length set to: 2
15:00:18.254:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):integrating 2 rows into cache at position 0
...
15:00:18.264:XRP7:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Cache for current criteria complete
15:00:18.274:XRP7:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):getRange(0, 1) satisfied from cache
...
Add record to table outside of SmartGWT
...
15:02:19.048:XRP4:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):dataSource data changed firing
15:02:19.067:XRP4:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):updating cache in place after operationType: undefined, allMatchingRowsCached true
15:02:19.086:XRP4:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):Updating cache: operationType 'undefined' (no componentID) ,3 rows update data:
...
But SelectItem still only shows the first 2 items
...
15:02:22.436:TMR5:INFO:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):setCriteria: filter criteria unchanged
15:02:22.440:TMR5:DEBUG:ResultSet:isc_ResultSet_7 (created by: isc_PickListMenu_1):getRange(0, 1) satisfied from cache
...
Think we may be missing something in our usage of DataSource.updateCaches() and/or how to force the SelectItem to render the new cache rows and wanted to check that with others before diagnosing further. Let me know if you need more from me on this.
Ed Reddy
Comment