Calling DataSource.updateCaches() doesn't rearrange ListGrid records when the update changes the value for a field on which the grid bound to the DataSource has sorting enabled AND the ListGrid has no full cache.
I can reproduce it on a 50 records clientonly datasource and a ListGrid with no full cache (ListGrid.drawAllMaxCells() disabled, ListGrid.drawAheadRatio() set to 1 and data page size reduced to 25) when I directly scroll to the table bottom (hence skipping the fetch of some records, so that the cache is not complete) and then I update the cache for record 45
See attached screenshot and code for a complete standalone example.
To reproduce the issue on the standalone example you should:
* load the page in dev mode
* press the scroll to row button or scroll to the record that you are going to update (by default it's 45, just to skip fetching some records)
* press the update cahches button
At this point the name field changes so that it should be repositioned to the top of the table (as per sorting defined on that field), while it remains on the original position.
I guess this happens when the local cache is not full, hence the ListGrid doesn't do a local sort. In fact the logs say
Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ResultSet'.
Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ListGrid'.
17:59:14.700:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
17:59:14.701:MUP9:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, cached rows: 44, total rows: 50
17:59:14.703:MUP9:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data:
[
{__ref: {GWT Java Obj},
id: 45,
name: "aaarow 45 with changed value!!!"}
]
17:59:14.707:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 0 row(s) added, 1 row(s) updated, 0 row(s) removed.
17:59:14.708:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):full length set to: 50
17:59:14.736:TMR3:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(38, 50) satisfied from cache
when updating row 45, while updating row 35 it says
17:59:55.822:MUP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
17:59:55.823:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, allMatchingRowsCached true
17:59:55.825:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data:
[
{__ref: {GWT Java Obj},
id: 35,
name: "aaarow 35 with changed value!!!"}
]
17:59:55.831:MUP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 0 row(s) added, 1 row(s) updated, 0 row(s) removed.
17:59:55.837:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):$391: sorting on properties [name] : directions [true] : full cache allows local sort
17:59:55.868:TMR7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(30, 42) satisfied from cache
I guess this behavior is by design... how could the client sort data if the entire dataset is not available?
So if there's no way to update an incomplete cache and still obtain valid record sorting should systematically invoke a fetch after ListGrid.updateCaches ()? This would waste the cache update... or should instead try to find a way to detect if the cache is full (hence allowing local sort): in this case proceed with the cache update, otherwise falling into a fetch?
Reproduced with SmartGWT 3.1 LGPL [SmartClient Version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)]
I can reproduce it on a 50 records clientonly datasource and a ListGrid with no full cache (ListGrid.drawAllMaxCells() disabled, ListGrid.drawAheadRatio() set to 1 and data page size reduced to 25) when I directly scroll to the table bottom (hence skipping the fetch of some records, so that the cache is not complete) and then I update the cache for record 45
See attached screenshot and code for a complete standalone example.
To reproduce the issue on the standalone example you should:
* load the page in dev mode
* press the scroll to row button or scroll to the record that you are going to update (by default it's 45, just to skip fetching some records)
* press the update cahches button
At this point the name field changes so that it should be repositioned to the top of the table (as per sorting defined on that field), while it remains on the original position.
I guess this happens when the local cache is not full, hence the ListGrid doesn't do a local sort. In fact the logs say
Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ResultSet'.
Global Log Priorities updated: Logging messages at priority 'Debug' and above for category 'ListGrid'.
17:59:14.700:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
17:59:14.701:MUP9:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, cached rows: 44, total rows: 50
17:59:14.703:MUP9:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data:
[
{__ref: {GWT Java Obj},
id: 45,
name: "aaarow 45 with changed value!!!"}
]
17:59:14.707:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 0 row(s) added, 1 row(s) updated, 0 row(s) removed.
17:59:14.708:MUP9:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):full length set to: 50
17:59:14.736:TMR3:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(38, 50) satisfied from cache
17:59:55.822:MUP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):dataSource data changed firing
17:59:55.823:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updating cache in place after operationType: update, allMatchingRowsCached true
17:59:55.825:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):Updating cache: operationType 'update' (no componentID) ,1 rows update data:
[
{__ref: {GWT Java Obj},
id: 35,
name: "aaarow 35 with changed value!!!"}
]
17:59:55.831:MUP5:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):updated cache: 0 row(s) added, 1 row(s) updated, 0 row(s) removed.
17:59:55.837:MUP5:INFO:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):$391: sorting on properties [name] : directions [true] : full cache allows local sort
17:59:55.868:TMR7:DEBUG:ResultSet:isc_ResultSet_0 (created by: isc_ListGrid_0):getRange(30, 42) satisfied from cache
I guess this behavior is by design... how could the client sort data if the entire dataset is not available?
So if there's no way to update an incomplete cache and still obtain valid record sorting should systematically invoke a fetch after ListGrid.updateCaches ()? This would waste the cache update... or should instead try to find a way to detect if the cache is full (hence allowing local sort): in this case proceed with the cache update, otherwise falling into a fetch?
Reproduced with SmartGWT 3.1 LGPL [SmartClient Version: v8.3_2012-11-20/LGPL Development Only (built 2012-11-20)]
Comment