Grid. Select all rows

I`m using Grid with multiple selection mode enabled.
And noticed unexpected behaviour by clicking on the checkbox in the header(“select all” checkbox).
Only first thousand rows are selected but the others not.
Am I doing something wrong or this was designed so?

Here is an example

Grid grid = new Grid();
grid.setSelectionMode(Grid.SelectionMode.MULTI);
grid.addColumn("id", Integer.class);
grid.addColumn("value", String.class);

for(int i = 0; i < 5000; i++) {
    grid.addRow(i, "Value" + i);
}

addComponent(grid);

22220.png

Hi,

It’s working as designed, yes. The default max selection size of MultiSelectionModel is 1000. The limit can be overridden by creating the MultiSelectionModel object explicitly, but you need to consider memory usage on the server. Example:

MultiSelectionModel selectionModel = new MultiSelectionModel(); selectionModel.setSelectionLimit(5000); grid.setSelectionModel(selectionModel); When you have more than 1000 rows, you should consider some other alternative than “select all”, if possible.

Makes sense, thanks a lot!

I have some similar problem that is as confusing as the one mentioned by Krill.

When I click on the header checkbox to select all rows, it only selects the first 1000, this behavior is definitelly wrong I would suggest if the selection is being made through the “select all” checkbox on the grid header that the default behavior be to really select all.

Can this be a feature request? Or a bug?

Thanks!

Hi,

the selection of only the first 1000 rows is indeed a design decision. It’s a compromise between functionality and performance. Fortunately it’s not a hard limit. You can work around it very easily (see above code snippet) if that’s what you need to do. Customizing the selection model has become even more versatile in Vaadin 7.6; see this
blog post that talks about it
for some more information.

Best regards,
Olli

Olli - I just encountered the same issue and found this thread. I have to side with David Hofmann here - this behavior is simply wrong. When I select “All”, I expect all rows to be selected - no matter the size of the list. I just came across this problem by accident - I happened to know that this particular screen would show more than 1000 entries and I just happen to have a printf statement in my selection callback that showed that only 1000 entries were actually selected.

But what if I hadn’t seen this? I would have ended up getting some weird customer support calls later from folks (rows in my Grid/database) who didn’t have changes applied to them - even though the person who made the changes swore all up and down that he made those changes to ALL users in the system?

I think that is a poor situation to let developers using your framework get into. At a minimum, I’d expect some exception or error dialog indicating that only a partial list was sent to the application layer - this way it’s at least more likely to be caught before the software goes into production.

I understand the resource consideration - and once a developer knows about the issue, he can implement the snippet you suggest, but if they don’t even know about the limitation/bug in the default implementation…

Hi,

I can see your point. It’s not a simple choice either way - if you consider the worst case scenario (and the framework must consider it), either the system doesn’t work quite as expected, or it fails completely. If you feel that you’ve got a solid argument for behavior that’s acceptable in all cases, please submit a ticket at
GitHub
so it’s not just forum discussion.

Kind regards,
Olli

Hi Olli,
I took your suggestion and opened a bug in GitHub with what I think is a reasonable solution:
https://github.com/vaadin/framework/issues/8158

Great, thanks!

My whole app is getting stuck (blue progress bar on top growing up forever) when I click this “select all” checkbox on the grid’s header for the select column. I’m on v7 with a grid with more than 50.000 rows. Have removed any possible listeners on the grid but same thing still happens. Suggestions welcome…