Opened 10 years ago
Closed 8 years ago
#12407 closed defect (wontfix)
JSonRestStore doesn't compute the results count correctly
Reported by: | rdunklau | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | tbd |
Component: | DojoX Data | Version: | 1.6.0rc1 |
Keywords: | ServiceStore scroll data | Cc: | |
Blocked By: | Blocking: |
Description
How to reproduce:
1) Create a DataGrid? based on a JSONRestStore.
2) Scroll to the bottom
What happens:
When reaching the bottom of the scrollbar, only the last fetched items are displayed, and the scrollbar disappears. Thiss seems to be caused by the "rowCount" being set to the last result set size
What should happen:
The grid rowcount should be set accordingly to the real result set size, not the last fetched page.
This code in JSonRestStore seems to be responsible for the bad behavior:
_processResults: function(results, deferred){ // index the results var count = results.length; // if we don't know the length, and it is partial result, we will guess that it is twice as big, that will work for most widgets return {totalCount:deferred.fullLength || (deferred.request.count == count ? (deferred.request.start || 0) + count * 2 : count), items: results}; },
Replacing count when fewer items are fetched with :
return {totalCount:deferred.fullLength || (deferred.request.count == count ? (deferred.request.start || 0) + count * 2 : count + deferred.request.start), items: results};
seems to resolve the bug.
Change History (3)
comment:1 Changed 10 years ago by
Owner: | changed from Jared Jurkiewicz to Kris Zyp |
---|
comment:2 Changed 10 years ago by
Thanks, I missed the "total count" part of the range headers, it solved my problem. However, I think my point is still valid: when the headers are not present, the result count could be returned as a "best-guess", thus allowing an implementer not to compute the total count on the service side.
comment:3 Changed 8 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
dojox/data is abandoned. Some dojox/data stores have been upgraded to use the Dojo Store API and can be found at https://github.com/kfranqueiro/dojo-smore.
Reassigning to JRS owner, Kris Zyp.
I don't think this is a JRS bug, though. I think you have an error in your service. JRS uses headers to control the size of the data and only resorts to the resultset size if the headers aren't set. You need to be setting the headers properly in your response. See JRS doc:
http://docs.dojocampus.org/dojox/data/JsonRestStore#paging
Please verify that you're sending back the right header.