angular-ui / ui-grid

UI Grid: an Angular Data Grid
http://ui-grid.info
MIT License
5.39k stars 2.47k forks source link

Documentation for large datasets only shows loading entire dataset #3113

Closed brockmatt closed 9 years ago

brockmatt commented 9 years ago

In the example for large datasets the table has to download the entire 10,000 row dataset in a single query. But I don't see any example that retrieves the data in pages.

PaulL1 commented 9 years ago

I'm not sure that's a defect. Perhaps the pagination tutorial would help?

brockmatt commented 9 years ago

Pagination works fine. What doesn't work fine is pulling a virtualized view of a larger dataset. The example pulls all 10,000 rows. What if that was a million rows? Requiring the user to query every row of a very large dataset contradicts the very purpose of virtualizing the display in the first place.

Perhaps you don't understand what I mean? Here is an example using a different framework. Notice how every row isn't grabbed on the first load? Instead, a page of rows is pulled as the table needs more data. Ergo, my initial question.

PaulL1 commented 9 years ago

Take a look at the useExternalPagination option in the api documentation: http://ui-grid.info/docs/#/api/ui.grid.pagination.api:GridOptions

I haven't done it myself, but I believe it works based on what others have said.

brockmatt commented 9 years ago

Thank you, Paul, that looks promising.

brockmatt commented 9 years ago

After going through the code I see that this feature simply isn't supported.

PaulL1 commented 9 years ago

I don't think that's true, it's supposed to be there and I'm sure I've seen people use it before. From reading the comments and a quick look in the code, I think the expected usage is that you listen to the paginationChangedEvent, and you then get the extra page of data that is requested, update the data, and set the totalItems variable to the appropriate value (I'm not quite sure what the appropriate value is, because I don't know whether the expected behaviour is to add the new data to the data array, or replace the old data array, although I guess the answer is that this is the total number of items available on the server - so it probably should stay constant).

You could consider using infiniteScroll instead, which has a similar effect and definitely gets pages of data from the server.

PaulL1 commented 9 years ago

OK, I've built a tutorial that demonstrates external pagination being used. It seems to work fine - I didn't have to do any code changes to get it working. Of course, I think often infinite scroll is a better ui design option, but that's a matter of preference no doubt.

brockmatt commented 9 years ago

Paul, I really appreciate your help in this matter but I don't think I'm making myself clear. I am not interested in pagination (Page 1 of X). As I said three days ago, pagination works fine. Splendidly, in fact. Just as the docs described! Unfortunately, that is not what I am trying to accomplish.

I put a link in the same comment three days ago demonstrating what I am getting at. There is no page selection there (Page 1 of X) so I don't understand why you keep going back to that paradigm. What I am looking for is a virtualized view of a data set, with a scrollbar that is scaled to the total number of items. This gives the user the illusion of having the entire grid, but without the expense of pulling all of the rows of data.

As the scrollbar is moved up or down, the code determines what page to select. As a very simple example, imagine a table with 10 rows displayed, and 100 rows total. The scrollbar is scaled to appear as though there are 100 rows. When you move the scrollbar down a row, the back end fetches the next 10 rows.

Please just look at the example I linked to. It's a lot easier than trying to describe it. It is similar to infinite scroll, except that infinite scroll is a fundamentally broken solution in that it doesn't properly scale the scrollbar to the correct height based on the total number of rows. Thus:

Edit: This is the direct link to the demo of what I'm describing

PaulL1 commented 9 years ago

OK, no I didn't click your link because I didn't take the time, you're correct there. But to be fair it really wasn't clear that you were talking about something other than pagination.

What you have showed an example of is basically an extension of infinite scroll where the scrollbar is adjusted to show the full dataset, and infinite scroll is capable of requesting an arbitrary page rather than just the next page. I am sure that could be added onto infinite scroll, but it's not something that infinite scroll does today. I don't think that means that I'd describe infinite scroll as 'fundamentally broken', but each to their own.