Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Refreshing a SelectItem in a ListGrid

    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:

    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);
    					}					
    				}
    			});
    		}
    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

    #2
    It looks like you're trying to pass a DSResponse from a fetchData() to updateCaches() - this is invalid - see docs for updateCaches, it expects responses that reflect modifications to data (update, add, remove).

    Comment


      #3
      Then it sounds like this strategy won't work for our problem. we're trying to pick up changes made by other users so we won't know the actual updates, adds or removes that occurred, we just want to reload all the data from the server.

      So to restate the problem, we have a ListGrid loaded with rows of data and one or more of the ListGridFields in the grid is using a SelectItem editor and the SelectItems have already been loaded with data from previous steps. So, based on clicking a Refresh button, how to do we reload the data in all the SelectItems to insure the dropdowns have the latest data from the server, including changes made by other users since the dropdowns data was originally loaded?

      Ed Reddy

      Comment


        #4
        You can call DataSource.updateCaches() with a DSResponse where invalidateCache has been set - all bound components will then drop their caches.

        Comment

        Working...
        X