[Dojo-interest] DataGrid and EnhancedGrid not paging JSON data properly.

163 views
Skip to first unread message

cardician

unread,
Dec 19, 2011, 3:28:51 PM12/19/11
to dojo-i...@mail.dojotoolkit.org
I'm really hoping someone can spare a few moments to help me. I have no idea why this is no longer working as I swear it was before but now no matter what I try I'm encountering this issue. I've got a Spring MVC app with Dojo as the front end. Everything was working pretty decently. In a a few places I'm displaying DataGrids that are getting their data from the app using JSON. The problem occurs when there is a lot of data in the tables (say for example 67 records). When I scroll down and the scrollbar hits the point where Dojo loads the next set, instead of doing that I'm getting a repeat of the current data. So, initially rows 1-25 are displayed, then when I hit the scroll/reload point, it displays rows 1-25 again. It's displaying the correct number of rows, so 67, but it just repeats the data. The same problem is occurring if I use an EnhancedGrid with the pagination plugin. When I click the link for the second page, it just displays the same rows from the first page again, and so on for the third page. Though on the third page there will only be 17 rows so give the correct total of 67 rows. I'm sure I must be screwing something up because I swear that at least the pagination part of the EnhancedGrid was working before but I have no idea why it would have stopped. Here is how I'm using the grids: <script type="text/javascript"> reportStore = new dojo.store.JsonRest({target:"/Condor/reports/data"}); reportGrid = new dojox.grid.EnhancedGrid({ store: dataStore = dojo.data.ObjectStore({objectStore: reportStore}), structure: [ {type: "dojox.grid._CheckBoxSelector"},[ {name:"Legal Authorization", field:"legalAuth", width: "200px"}, {name:"Program Name", field:"programName", width: "200px"}, {name:"Start Date", field:"startDate", width: "100px", formatter: formatDate, constraint: {formatLength: 'long', selector: "date", datePattern: "MMM d, y"}}, {name:"End Date", field:"endDate", width: "100px", formatter: formatDate, constraint: {formatLength: 'long', selector: "date", datePattern: "MMM d, y"}}, {name:"Username", field:"username", width: "80px"}, {name:"Active", field:"enabled", width: "50px"}, {name:"IP(s)", field:"targetIP", width: "200px"}, {name:"Matched", field:"matched", width: "100px"} ]], plugins:{pagination: true} }, "report-node-id"); // make sure you have a target HTML element with this id reportGrid.startup(); </script>
That's basically it. What's really weird is that if I make the browser window smaller in height so that the scrollbar is forced to scroll more, then this problem goes away and the proper data is loaded when dojo calls the next set of data. I'm sure that's a big indication of the problem but I can't seem to figure out how to make this work like it is supposed to. Anyone with any thoughts?

View this message in context: DataGrid and EnhancedGrid not paging JSON data properly.
Sent from the Dojo Toolkit mailing list archive at Nabble.com.

zhuxw

unread,
Dec 19, 2011, 11:22:46 PM12/19/11
to dojo-i...@mail.dojotoolkit.org
Hi, first you need to make sure your store is working correctly. Write some
code snippets like this:
dataStore.fetch({
start: 0, //Change the start index to mimic the grid's paging
behavior.
count: 25, //Better to be the page size, 25 by default.
onComplete: function(items){
//Check whether all the items are correct.
console.log(items);
}
});
Maybe you will need to debug your server side logic to make sure your are
receiving correct requests and sending correct responses.

-----
Best Regards
-------------
Oliver
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DataGrid-and-EnhancedGrid-not-paging-JSON-data-properly-tp3599493p3600313.html


Sent from the Dojo Toolkit mailing list archive at Nabble.com.

________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

Dojo-i...@mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Jared Jurkiewicz

unread,
Dec 19, 2011, 11:32:05 PM12/19/11
to dojo-i...@mail.dojotoolkit.org
Most likely your backend service is not honoring start/count values
passed by the data store. You don't specify what data store you use,
so I cannot point you to the doc describing what server
implementations are expected. If it is, perhaps, JsonRestStore, then
your server code needs to handle range headers properly. See doc:

http://livedocs.dojotoolkit.org/dojox/data/JsonRestStore

Sincerely,
-- Jared Jurkiewicz

Jared Jurkiewicz

unread,
Dec 19, 2011, 11:32:30 PM12/19/11
to dojo-i...@mail.dojotoolkit.org

cardician

unread,
Dec 20, 2011, 10:12:49 AM12/20/11
to dojo-i...@mail.dojotoolkit.org
Thank you very much for the responses. Specifically Jared, thank you very
much for that link. It contained exactly what I believe was missing. It
specified that I needed to set Content-Range in the response header which I
hadn't done the last time I tried to implement range. This time I
re-implemented handling the range argument in the request and added the
Content-Range to the response and things started working properly. Maybe no
I can successfully implement sorting as well.

It just seems odd to me that making the browser window smaller would also
eliminate this issue without implementing handling of the range argument.

Again, thanks to all for taking the time to reply and help.

--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/DataGrid-and-EnhancedGrid-not-paging-JSON-data-properly-tp3599493p3601416.html

Reply all
Reply to author
Forward
0 new messages