Cant make page number of datatable dynamic [premium support]
Closed this issue · 4 comments
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [ yes] I am running the latest version
- [yes ] I checked the documentation and found no answer
- [yes ] I checked to make sure that this issue has not already been filed
- [ yes] I'm reporting the issue to the correct repository (for multi-repository projects)
Expected Behavior
To add laravel way of pagination links in blade and it works normally
Current Behavior
it is not sync with the current implementations, the page number in items sample page is not dynamic and cant sync it with normal pagination
Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- Add {{ $users->links() }} under table of page items
- Number of pages is the same
Context
- Device: pc
- Operating System: windows
- Browser and Version: ltest chrome
Failure Logs
Please include any relevant log snippets or files here.
Hello,
Thank you for using creative TIM!
You should be able to find what you need in the original code of the template. You can find the pagination that works here --> https://www.creative-tim.com/live/argon-dashboard-pro-laravel
Best.
The pagination exists in form of HTML not in laravel way of implementation
Now the project is using the pagination from Datatables Bootstrap5 as you can see in the index.blade.php of category, tag, user, item and role files. To change to Laravel pagination you will need to follows some steps:
- In app/Providers/AppServiceProvider.php add at the top of the file
use Illuminate\Pagination\Paginator;
and in the function boot add this change
public function boot()
{
Paginator::useBootstrap();
}
-
For your table, go to the controller associated with it, for example if I want to add Laravel pagination to User table you will got to app/Http/Controllers/UserController and in the funtion index I will make the update to
public function index(User $model)
{
$this->authorize('manage-users', User::class);
return view('laravel.users.index', ['users' => $model->paginate(5)]);
} -
Now you can go to your table in resources/laravel/users/index.blade.php and add after you closing tab for
{{ $users->links() }} -
In the same resources/laravel/users/index.blade.php file, where the @Push('js') takes place you will need to remove the pagination from the Datatable Bootstrap 5 by adding paging: false`` like this
<script> const dataTableBasic = new simpleDatatables.DataTable("#datatable-basic", { searchable: false, fixedHeight: true, paging: false, columns: [{ select: [2], sortable: false }] }); </script>Let us know if that helps.
It works thanks you very much