Level 1
Please answer this question as I am stuck
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have included the following code in my controller
$provider = new EloquentDataProvider(User::class);
//$provider = new DbTableDataProvider($pdoConnection, 'my_table');
$input = new InputSource($_GET);
$columns = [
'id' => new Column('Edit'),
'name' => new Column('name'),
'address' => new Column('address'),
'contactno'=> new Column('contactno'),
'email'=> new Column('email'),
'deleterec' => new Column('Delete Record')
];
// create grid
$grid = new Grid( $provider, $columns,
[
new PaginationControl($input->option('page', 1), 5), // 1 - default page, 5 -- page size
new PageSizeSelectControl($input->option('page_size', 10), [2, 5, 10]),// allows to select page size
new ColumnSortingControl('id', $input->option('sort')),
new FilterControl('name', FilterOperation::OPERATOR_LIKE, $input->option('name')),
new CsvExport($input->option('csv'))
]
);
// all components are optional, you can specify only columns
//new TableCaption('My Grid'),
$columns['id']->setValueFormatter(function ($id, $row) {
return "<a href='". url('/editrecord')."/{$row->id}'>Edit</a>";
})
->getDataCell()
->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
->setAttribute('style', 'cursor:pointer');
$columns['deleterec']->setValueFormatter(function ($id, $row) {
return "<a href='". url('/deleterecord')."/{$row->id}'>Delete</a>";
})
->getDataCell()
->setAttribute('onclick', 'window.location = $(this).find(\'a\').attr(\'href\'));')
->setAttribute('style', 'cursor:pointer');
// but also you can add some styling:
$customization = new BootstrapStyling();
$customization->apply($grid);
return view('mynewgrid', compact('grid'));
But now I have the following problem
pagination , page size select control are not displaying in grid
Please or to participate in this conversation.