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

Added helper method to get the amount of rows from the Grid #8786

Closed
wants to merge 3 commits into from

Conversation

mstahv
Copy link
Member

@mstahv mstahv commented Mar 8, 2017

closes #8679


This change is Reviewable

@hesara
Copy link
Contributor

hesara commented Mar 9, 2017

Reviewed 1 of 2 files at r1.
Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion.


server/src/main/java/com/vaadin/ui/Grid.java, line 3419 at r1 (raw file):

    /**
     * @return the amount of rows in this Grid

number of rows
(I would have fixed this myself, but don't seem to have push access to the PR branch)


Comments from Reviewable

@mstahv
Copy link
Member Author

mstahv commented Mar 9, 2017

Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion.


server/src/main/java/com/vaadin/ui/Grid.java, line 3419 at r1 (raw file):

Previously, hesara (Henri Sara) wrote…

number of rows
(I would have fixed this myself, but don't seem to have push access to the PR branch)

Don't know why. I'm pretty sure the checkbox was on when I did the PR. I checked that on now (after the PR was done).


Comments from Reviewable

@pleku
Copy link
Contributor

pleku commented Mar 9, 2017

Review status: 1 of 2 files reviewed at latest revision, 2 unresolved discussions.


a discussion (no related file):
I'm not even sure if we want to add this method, especially like this as it can have some performance indications and requires lot of explaining.

The simplified version could be to cache the latest reported size in data communicator, and then delegate the added size() method to fetch that.


Comments from Reviewable

@mstahv
Copy link
Member Author

mstahv commented Mar 9, 2017

The need to get the number of rows is so common that the method for sure is needed. I personally don't care at all how it is implemented. I know nothing about Grid's internals (and don't want to know at this point), so I just copied the implementation from the Grid class from an other place where the number of rows was needed. If the size query is slow in the backend, developers probably need to cache that somehow anyways. If this could be optimised at Grids level, it could be done later.

@pleku
Copy link
Contributor

pleku commented Mar 9, 2017

Review status: 1 of 2 files reviewed at latest revision, 2 unresolved discussions.


a discussion (no related file):

Previously, pleku (Pekka Hyvönen) wrote…

I'm not even sure if we want to add this method, especially like this as it can have some performance indications and requires lot of explaining.

The simplified version could be to cache the latest reported size in data communicator, and then delegate the added size() method to fetch that.

Yeah my concern is just that with the current implementation, it is not the number of rows in grid, but the number of rows in the used backend. The grid might actually have different amount of rows visible if the data set has changed and grid hasn't been updated. So for the use case, visualize number of rows in grid, this is not a valid solution.

I might push another patch for this that used as cached value from data provider, thus it would be lot simpler.


Comments from Reviewable

@mstahv
Copy link
Member Author

mstahv commented Mar 9, 2017

See this as well (I don't know how Grid works, but you might want to use the cached value here as well):
https://github.com/mstahv/framework/blob/e86c18bbe155d6bb7381feb6b0873441c44a8a7b/server/src/main/java/com/vaadin/ui/Grid.java#L3397

@pleku
Copy link
Contributor

pleku commented Mar 9, 2017

Thanks, I'll fix that too

@pleku
Copy link
Contributor

pleku commented Mar 22, 2017

Closing this PR because it has multiple issues, described in the ticket #8679, and this approach just won't work.

@pleku pleku closed this Mar 22, 2017
@tsuoanttila tsuoanttila added this to the Invalid milestone Apr 30, 2018
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

Successfully merging this pull request may close these issues.

Grid should have a function to get the total number of rows
4 participants