Thanks Jason!  Here is the complete function if anyone is curious:

sub basic_data {
>     my $self = shift;
>     my $params = shift;
>     my $table = $params->{table};
>     my $search = $params->{search};
>     my $columns = $params->{columns};
>     my $rows = $self->query->param('limit') || 25;
>


    # our framework gives us an amount to skip instead of a page number.
>     my $page = ($self->query->param('start')?(
> $self->query->param('start')/$rows + 1 ):1);

    # this is a little kludgey, but we must have a sort, so if there isn't
> one we just sort by id.
>
    my $order_by =
> ($self->query->param('sort')?$self->query->param('sort').'
> '.$self->query->param('dir'):'id');
>     use DBIx::Class::ResultClass::HashRefInflator;
>     my $rs_full = $self->schema()->resultset($table)->search($search,{
>         order_by => $order_by,
>         columns => $columns,
>     });
>     my $data = { data => []};
>     $data->{total} = $rs_full->count;
>     my $rs = $rs_full->search({},{
>         rows => $rows,
>         page => $page,
>     });
>     $rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
>     while (my $operation_code = $rs->next() ) {
>         push @{$data->{data}}, $operation_code;
>     }
>     return $self->json_body($data);
> }
>


-- 
fREW Schmidt
http://blog.afoolishmanifesto.com
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to