Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

majacirkova's avatar

Pagination with Nayjest data grid

Hello , i m using Nayjest data grid , is there some option to generate pagination links from some query in Laravel 5. Pager only show number of pages without links.Do you have some examples to show me how to use it ?

0 likes
9 replies
majacirkova's avatar

This is result from nayjest grid

Result picture

 ->setComponents([
            (new TotalsRow(['posts_count', 'comments_count'])),
            (new TotalsRow(['posts_count', 'comments_count']))
            ->setFieldOperations([
            'posts_count' => TotalsRow::OPERATION_AVG,
            'comments_count' => TotalsRow::OPERATION_AVG,
        ])
         ,
            (new OneCellRow)
            ->setComponents([

            (new HtmlTag)
            ->setAttributes(['class' => 'pagination'])
            ->addComponent(
            new ShowingRecords)
           ,
            (new HtmlTag)
            ->setAttributes(['class' => 'pagination'])
            ->addComponent(
                new Pager)
              ])
   ])

But I want to show like this picture bellow :

mstnorris's avatar

You mean like this http://laravel.com/docs/5.0/pagination

<div class="container">
    <?php foreach ($users as $user): ?>
        <?php echo $user->name; ?>
    <?php endforeach; ?>
</div>

// this is the line you care about
<?php echo $users->render(); ?>
majacirkova's avatar

But here $users is some variable, i m using $grid variable where im setting with model :

 $grid = new Grid(
            (new GridConfig)

                ->setDataProvider(
                    new EloquentDataProvider(Contact::get_all_contacts())
                )
                ->setName('contacts_grid')
                ->setPageSize(5)

                ->setColumns([  ..

And I ' cant use this : render(); ?> show me this error: Call to a member function render() on a non-object

Nayjest's avatar

Hi!

@majacirkova, so problem was becouse you used Laravel4 Pager implementation in Laravel 5 project or becouse you tried to render it directly inside tbody tag (browsers will not render some incorrectly placed tags inside tables)? Or there was some another problem?

majacirkova's avatar

Hi ! @Nayjest , the problem was that i haven't included this in controller function that i used Nayjest grid implementation:

(new RecordsPerPage)
    ->setVariants([
        50,
        100,
        1000
    ])
, ... ```

Please or to participate in this conversation.