[Catalyst] Paging support in Catalyst::Controller::DBIC::API

Rajesh Kumar Mallah mallah at redgrape.tech
Wed Mar 29 10:05:16 GMT 2017



Thanks , It does return *when* paging related params are passed.
I have now used that result in my code.


Kind Regds
mallah.

> Hi,
>
> it does return it in the totalcount property by default.
>
> The name can be configured with the 'total_entries_arg' config parameter:
>
 https://metacpan.org/pod/Catalyst::Controller::DBIC::API#count_arg,-page_arg,-select_arg,-search_arg,-grouped_by_arg,-ordered_by_arg,-prefetch_arg,-as_arg,-total_entries_arg
>
> Best regards, Alex
>
> On 2017-03-19 18:38, Dimitar Petrov wrote:
> Hello Rajesh,
>
> I usually have my own: MyApp::REST which extends
>
> package MyApp::REST;
> use Moose;
> use Try::Tiny;
> use DBIx::Class::ResultSet::RecursiveUpdate;
> use Scalar::Util qw( reftype );
>
> BEGIN { extends 'Catalyst::Controller::DBIC::API::REST' }
>
> with 'Iris::Web::TraitFor::Controller::Datatables';
>
> ….
>
> and later on modifier:
>
>
> =head2 list_format_output
>
> Add more information about current search
>
> =cut
>
> after 'list_format_output' => sub {
>   my ($self, $c) = @_;
>
>   if (!$self->has_errors($c) && $c->req->has_search_total_entries) {
>     my $current_result_set = $c->req->current_result_set;
>
>     $c->stash->{ $self->stash_key }{last_page}            =
> $current_result_set->pager->last_page + 0;
>     $c->stash->{ $self->stash_key }{current_page}         =
> $current_result_set->pager->current_page + 0;
>     $c->stash->{ $self->stash_key }{entries_per_page}     =
> $current_result_set->pager->entries_per_page + 0;
>     $c->stash->{ $self->stash_key }{entries_on_this_page} =
> $current_result_set->pager->entries_on_this_page + 0;
>   }
> };
>
> Best regards,
>
>
> On Mar 19, 2017, at 09:28, Rajesh Kumar Mallah
> <mallah at redgrape.tech<mailto:mallah at redgrape.tech>> wrote:
>
> Hi ,
>
> We know that Catalyst::Controller::DBIC::API supports paging
> via list_count  , list_page and list_offset  options and
> its possible to fetch a page of a large result set.
>
> However what it does not seems to support is to tell
> the View(caller) of how many records in total exists , ie
> the total_entries of the Data::Page object.
>
> This compels us to make two queries one to get the total count
> and another to get the paged result.
>
> Does this feature really does not exists or am I missing something?
>
> (The reason I love and thoroughly use Catalyst::Controller::DBIC::API is
> that it allows me to be lazy :p )
>
> regds
> Rajesh Kumar Mallah.
>
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk<mailto:Catalyst at lists.scsys.co.uk>
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk<mailto:Catalyst at lists.scsys.co.uk>
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
>
>
 *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
> Handelsgericht Wien, FN 79340b
>
 *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> Notice: This e-mail contains information that is confidential and may be
> privileged.
> If you are not the intended recipient, please notify the sender and then
> delete this e-mail immediately.
>
 *"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>







More information about the Catalyst mailing list