Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading problem with JsonRest store with paging (height is set to 'auto') #54

Closed
mchamplain opened this issue Dec 5, 2011 · 5 comments

Comments

@mchamplain
Copy link

I'm trying to use a OnDemandGrid with a JsonRest store, it works for the first page of data, but when I scroll down to see other results, I see that another call is made to the server with a different range, but the grid is not updating correctly. Server side I return the Range-Content as described in the documentation.

JS code:

require([
    "dgrid/OnDemandGrid",
    "dojo/_base/declare",
    "dojo/store/JsonRest",
    "dojo/store/Cache",
    "dojo/store/Memory",

    "dojo",
    "dojo/domReady!"
    ],
    function(Grid, declare, JsonRest, Cache, Memory){

        //  define the column structure on the main grid, and create it.
        var columns = [
        {
            label: 'Id',
            field: 'id'
        },
        {
            label: 'Name',
            field: 'name'
        }
        ];

        var productGroupStore = Cache(JsonRest({target:"/mock/productgroups/"}), Memory());

        window.grid = new (declare([Grid]))({
            store: productGroupStore,
            columns: columns,
            minRowsPerPage: 5,
            maxRowsPerPage: 5
        }, "grid");


    }   //  end "main" function
);  //  end require

The json return on the first call to /mock/productgroups/
[{"id":70926,"name":"Fake Product"},{"id":580689,"name":"Fake Product"},{"id":801159,"name":"Fake Product"},{"id":335780,"name":"Fake Product"},{"id":985208,"name":"Fake Product"}]

and the headers for that call:
Status Code:200 OK

Request Headers:
Accept:application/javascript, application/json
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Type:application/x-www-form-urlencoded
Range:items=0-4
X-Requested-With:XMLHttpRequest

Response Headers:
Connection:Keep-Alive
Content-Length:180
Content-Type:text/x-json;charset=UTF-8
Keep-Alive:timeout=15, max=70
cache-control:no-cache
content-range:0-4/500

And when I scroll the grid to see other results, here's the result:
[{"id":174082,"name":"Fake Product"},{"id":397380,"name":"Fake Product"},{"id":403586,"name":"Fake Product"},{"id":921312,"name":"Fake Product"},{"id":379202,"name":"Fake Product"}]

and corresponding headers:

Request Method:GET
Status Code:200 OK

Request Headers:
Accept:application/javascript, application/json
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Type:application/x-www-form-urlencoded
Range:items=5-9
X-Requested-With:XMLHttpRequest

Response Headers:
Connection:Keep-Alive
Content-Length:181
Content-Type:text/x-json;charset=UTF-8
Keep-Alive:timeout=15, max=62
cache-control:no-cache
content-range:5-9/500

@kriszyp
Copy link
Contributor

kriszyp commented Jan 21, 2012

I put together a more comprehensive test case for JsonRest to demonstrate how the paging, saving, and deleting works:
https://github.com/kriszyp/dgrid/tree/rest

@mchamplain
Copy link
Author

I had to do some changes to the application layout, so I gave dGrid another try, turns out that it's working properly, but the grid is not loading other pages if the height is set to 'auto'. I didn't have time to investigate more.

@kriszyp
Copy link
Contributor

kriszyp commented Jan 21, 2012

The height of the rows or the height of the grid is set to auto?

@mchamplain
Copy link
Author

height of the grid. If I remember correctly, the grid was in a dijit content pane, with a div on top of it to hold a few buttons, (so height of 100% didn't work).
With height: auto, the grid filled the available correctly but when scrolling down the new results didn't appear anywhere (the json call is triggered).
At the end I wrapper the content pane in a Bordercontainer, with the grid as the only content of the center ContentPane, and putting the buttons in the header content pane. that work since I can set the height to 100%

@kriszyp
Copy link
Contributor

kriszyp commented Feb 7, 2012

I am still not sure I understand how to reproduce this. By itself setting height: auto; on the grid will normally result in a zero height (since the overflow setting doesn't require that the grid take up any space). If you are using height: auto; in combination with making the scroller non-scrolling (overflow: visible) than scrolling doesn't take place there is no scrolling to be done, all the rows should be shown. If you want the grid to take up all the space of a parent except for a certain amount of space, you should probably use an absolutely positioned grid with top and bottom properties set to position it. with the right amount of margins.

@kriszyp kriszyp closed this as completed Feb 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants