Subject: | Total Count for paging |
Hi,
I had issues with extjs grid paging, it wasnt able to get hold of the
total number of records available. I followed it back and it is handled
by the directstore->proxy->reader->totalProperty
this is gotten from result:{data:[],total:""} in the response.
I had to modify the result returned as shown below. as the comment
states this will mean that on the reader you will have to modify root to
be data and totalProperty to be totalCount but from now if you supply a
total number of records to c->req->params it will get parsed back and
paging toolbars will work
--- perl5/perlbrew/perls/perl-
5.14.2/lib/site_perl/5.14.2/CatalystX/Controller/ExtJS/Direct/API.pm
2012-10-16 11:22:48.000000000 +0100
+++ API.pm 2012-10-16 11:22:25.000000000 +0100
@@ -186,7 +186,10 @@
}
my $res = { map { $_ => $req->{$_} } qw(action method tid type)
};
- push( @res, { %$res, result => $body});
+ # We want to allow for total count used for grid paging, however
this changes
+ # the way result is returned, to get working in ext you will
need to modify the
+ # proxy's reader and set root = "data" and totalProperty =
"totalCount"
+ push( @res, { %$res, result => {data=>$body,totalCount=>$c-
Show quoted text
>req->params->{'totalCount'}}});
}
$c->stash->{rest} = @res != 1 ? \@res : $res[0];