-
7 Aug 2012 9:07 AM #1
Answered: Paging doesn't work
Answered: Paging doesn't work
Hi there,
I followed the PagingGridExample.java from the explorer demo. The code is exactly the same, except that I am using my own DataItem instead of Post. As well, instead of being its own class, I just have a method "createTable()" that runs the code found inside PagingGridExample.java asWidget() . I'm having a few problems with it though.
The grid loads, however paging doesn't work. I set:
However, even though the toolbar shows and shows the text: "Displaying 11 - 20 of 28", etc, the grid shows all 28 rows. When I click the buttons in the paging toolbar, the grid refreshes, but still shows all 28 rows on each page.Code:final PagingToolBar pagingToolBar = new PagingToolBar(10);
Also, the paging tool bar is unusually thick. I have to change the parameters of the VerticalLayoutData in order for it to show:
The overall layout is a DockLayoutPanel with a gxt TabPanel in the center. The grid is placed on a tab within a gwt VerticalPanel. All the other code is the same as in the example, except as noted above.Code:VerticalLayoutContainer con = new VerticalLayoutContainer(); con.setBorders(true); con.add(grid, new VerticalLayoutData(1, 0.80)); con.add(pagingToolBar, new VerticalLayoutData(1, 0.20));
I have attached a screenshot. Would appreciate any help!
Screenshot_grid.jpg
-
Best Answer Posted by icfantv
Let's break this down into the two issues you mention: 1) pagination, and 2) layout.
Pagination:
I suspect you are loading all 28 items in to your list store. I've only used remote loaded grids and I believe that the grid will not magically paginate, but rather will, assuming you are using a proxy, send the PagingLoadConfig (or FilterPagingLoadConfig) to the server and the onus is on your servlet and/or business logic to read the limit and offset and only send those items back, along with a total count.
Layout:
You are telling the paging tool bar to take up 20% of the container and it likely doesn't need that much. Try using a 1, -1 for your paging tool bar and change your grid to a 1, 1. This will tell the outer container to use the actual height of the paging tool bar and tell the grid to use the rest.
Alternatively, you could use a FlowLayoutContainer, but you will need to ensure that the added items have size and position because FlowLayoutContainer (along with CssFloatLayoutContainer) do not size or position its children.
-
7 Aug 2012 12:26 PM #2
Let's break this down into the two issues you mention: 1) pagination, and 2) layout.
Pagination:
I suspect you are loading all 28 items in to your list store. I've only used remote loaded grids and I believe that the grid will not magically paginate, but rather will, assuming you are using a proxy, send the PagingLoadConfig (or FilterPagingLoadConfig) to the server and the onus is on your servlet and/or business logic to read the limit and offset and only send those items back, along with a total count.
Layout:
You are telling the paging tool bar to take up 20% of the container and it likely doesn't need that much. Try using a 1, -1 for your paging tool bar and change your grid to a 1, 1. This will tell the outer container to use the actual height of the paging tool bar and tell the grid to use the rest.
Alternatively, you could use a FlowLayoutContainer, but you will need to ensure that the added items have size and position because FlowLayoutContainer (along with CssFloatLayoutContainer) do not size or position its children.
-
7 Aug 2012 12:43 PM #3
That worked perfectly! I didn't realize that I had to give the list store the size of chunks that I wanted. For the other issue, I had changed it originally to 80% and 20% because I couldn't see it otherwise. But after fixing the paging issue, I changed it back to the values you suggested and the table shows perfectly.
Thanks!
-
7 Aug 2012 1:20 PM #4
you're welcome and glad to help.


Reply With Quote