Closed chescos closed 6 years ago
Agreed, was looking for something similar #305. Number of pages, records returned, etc.
Honestly thought pagination like this would be a baseline feature... i'd hardly call it advanced it's just standard for any index/listing admin interface. Hopefully this will get implemented soon because I don't see any way to do it easily and Nova is fairly useless without it IMO.
It's done this way because it can be really resource intensive/slow to calculate that on really large datasets.
@davidhemphill do you consider adding it as an optional setting that could be enabled through a property on the resource? It could be disabled by default and enabled by adding something like public static $advancedPagination = true;
to the resource.
Your concern makes a lot of sense but still, I believe that this feature is pretty important to many people.
I've noticed that the request to get the required information for this is already currently being done in nova. If you check the network tab in chrome you can see a request that returns the current count of a resource including any filters and search results applied.
For example searching on a user resource will already run a request for:
/nova-api/users/count?search=username&filters=&perPage=25&trashed=&page=1
Which returns: {"count":1}
. It's just not being displayed on the index.
It's done this way because it can be really resource intensive/slow to calculate that on really large datasets.
@davidhemphill hmm this is not good. i understand there may be performance concerns on huge datasets but that doesn't mean this feature isn't necessary or warranted. this is a really basic requirement for an admin system.
I tend to agree with the above comments that this is needed. I've just spent a few days converting an app from Backpack to Nova and now I may have to forget that as the client I've done this for uses the pagination as part of their workflow. It is a growing dataset of about 10K records that its needed for.
You would think that Nova would follow Laravel's methodology and use paginate()
by default and provide an option to use simplePaginate()
for large datasets when you do not need to display a link for each page number.
I think this is a basic admin panel feature, the paginate methods of laravel api works good.
Disagree I don't see skipping from page 1 to 4 to 7 to 8 as mission critical like others above.
I think that with 5 tables on a page, the less clutter the better
I’d normally agree except for one project where it is which is why I think it should be an option. If it isn’t mission critical for you, you don’t need to enable it.
@sdmpxs can you describe why a user needs to jump from page 1 to 3 to 7 as a required workflow? Honestly don’t see the usefulness that ordering and searching and next and previous doesn’t satisfy?
@dillingham seriously? have you ever used another admin interface? could you not even envisage why it might be useful for a user to know how many results they are browsing? are you actually saying that "less clutter" is a reason to deny features?
if this is really not something you consider reasonable, then why does laravel have a paginate() method? why does almost every data-led admin system in the world use pagination for result sets? it's so unbelievable basic, even MS Access had it in like 1997.
As someone who wants the feature you should be able to defend its value lol am I not allowed to disagree, with actual points, not just everyone does it and “don’t enable it” while I ask why you NEED it? :)
And I didn’t say anything about “result count” that makes sense. I said I disagree with that linking 1-2-3-4-5 is valuable in comparison to the clutter it creates.
The Nova tables could at least show a small text "showing x of y results" in the bottom of the table, cause I think that I don't need a metric card to show the total rows of the table.
I agree that jumping from page 5 to 7 or from page 5 to 3 isn't that important. But I am really missing the total result count. This is so important for many situations, e.g when you want to know how many orders a customer has in total, or how many failed transactions a customer has (using a filter).
The value is this: it enables the user to navigate through the result set in a way that provides designation of their current position, provides knowledge of the size of the result set, and allows the user to jump forward or backward in defined chunks.
For example, if you are browsing an alphabetical list of 1000 records all beginning with A in page sizes of 100, then you might have an inkling that the records you're most interested in are on around page 4 or 5. If you only have forward and backward that would be several mouse clicks away. User interface design isn't solely about making things look uncluttered, it's also about providing a suitable navigation experience and ensuring the user understands where they are etc.
All that said, the result count is arguably more important than the paginated navigation which I can understand some people not seeing a use case for. However, since the original objection was because DB counts are expensive, then if the result count is included (and therefore the final page number is known) then it's hard to see a reason not to also provide an option for a fuller pagination.
The header label could have a small badge with count that changes when filtering and showing an updated count
If the resource count is shown (which we all seem to agree is absolutely necessary), then a page count and a "go to page" within the pagination would perhaps be a compromise over a full pagination nav bar.
That said, I still don't understand the idea that optional features should be denied because some people don't like or want them... surely a generic admin system should be usable for as wide a range of requirements as possible?
Anyways, I don't see a reason why both features (advanced pagination and row count) couldn't be added to Nova as an optional feature which needs to be enabled on the resource. Sure, performance might be an issue on big tables and maybe some people want a cleaner look. Making them optional removes this issue. Those features are very basic CRUD admin panel features and they are trivial to implement with Laravel and Vue. Many people expect them to be there because they are usually found in any CRUD admin panel and they have proven to be useful. I hope this still gets added.
I agree, this feature is needed.
Laravel already has pagination and knows how to return pagination responses on API requests including any needed meta information.
current_page | 1 |
---|---|
data | […] |
first_page_url | "http://page.local?page=1" |
from | 1 |
last_page | 2 |
last_page_url | "http://page.local?page=2" |
next_page_url | "http://page.local?page=2" |
path | "http://page.local" |
per_page | 50 |
prev_page_url | null |
to | 50 |
total | 75 |
I do not see how this impacts performance, it does not matter if 50 or 5,000,000 records
Should not really be a problem. Why reinvent the wheel? :-)
Nova now shows the current and total results in the bottom of the footer.
@davidhemphill The last update that I see on the Releases page is from October 25, 2018 (3 weeks ago), are you talking about a future release? Just a little confused because you said Nova now shows [...]
.
The resource current/total count has been added to the bottom of the footer and will be included in an upcoming release.
Does this mean the option for full pagination will be coming soon?
Not necessarily but I'll be looking into it soon.
Hi @davidhemphill
Quick question, is there a way to limit the number of records returned in the pagination? Let's say I want the first 20 records. Currently, Nova just returns the last 5 records.
Thanks in advance.
@davidhemphill I can prepare code for PR if need.
PR was send to upstream. Looks like that:
Currently the "25/150 resources" is more confusing when you click next & it doesnt change
(perPageCount * pageNumber) . '/' . totalCount "50/150"
(totalCount / perPageCount) / pageNumber .'/'. (totalCount / perPageCount) "2/6"
also would love it if it didnt say "resources" 50/150 is clear enough to me & doesnt add context
@dkulyk would love to see that implemented. :heart:
Maybe after New Year holidays.
Definitely would like to see pagination improvements, including:
I agree with @thechrisroberts - pagination still needs a lot of improvements, and it's currently poorly implemented. Just look at how other admin panels and data table libraries do it. No need to reinvent this, pretty much everyone is doing the same thing and it works great:
There's going to be some work on advanced pagination, but got some other priorities first. Will update this thread when we get there.
Documentation says:
By default, Nova Resources are displayed using the "simple" style. However, you may customize this to use the "links" style. You can enable this by setting the
pagination
option in yourapp/nova.php
configuration file:
Absolutely not clear. What is this app/nova.php
config file? Can not find it anywhere.
Documentation says:
By default, Nova Resources are displayed using the "simple" style. However, you may customize this to use the "links" style. You can enable this by setting the
pagination
option in yourapp/nova.php
configuration file:Absolutely not clear. What is this
app/nova.php
config file? Can not find it anywhere.
pagination config only for nova 2.x now
pagination config only for nova 2.x now
I recently updated to Nova 2.0, may be the reason is that I updated but not made a fresh install. Can not understand where to look for app/nova.php
config file.
pagination config only for nova 2.x now
I recently updated to Nova 2.0, may be the reason is that I updated but not made a fresh install. Can not understand where to look for
app/nova.php
config file.
look at this
https://github.com/laravel/nova/blob/ed076595b2b5b42c5153572de82954759e8dc7a3/config/nova.php#L92
u may run php nova:publish
after upgrade?
https://github.com/laravel/nova/blob/ed076595b2b5b42c5153572de82954759e8dc7a3/config/nova.php#L92
Not found :(
u may run php nova:publish after upgrade?
don't remember, will try now
Running nova:publish
updated published nova resources and now adding 'pagination' => 'links',
to
config/nova.php
did the switch. (Before running nova:publish
it did nothing of course).
So, documentation should be fixed:
"You can enable this by setting the pagination
option in your app/nova.php
configuration file" should be "You can enable this by setting the pagination
option in your config/nova.php
configuration file".
The last question is how to display 100 records per page, not 25.
@davidhemphill the docs say app/nova.php for setting the pagination to links, should be config/nova.php. Simple one, but people here seem to be having trouble with it.
The resource pagination should be improved. Currently, there is only a "Previous" and a "Next" button and no information whatsoever.
I'd like to see something like that on the bottom left:
And something like that on the bottom right: