Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant make page number of datatable dynamic [premium support] #45

Closed
heshamwatany opened this issue Jul 21, 2023 · 4 comments
Closed

Cant make page number of datatable dynamic [premium support] #45

heshamwatany opened this issue Jul 21, 2023 · 4 comments

Comments

@heshamwatany
Copy link

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.

  1. Add {{ $users->links() }} under table of page items
  2. 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.

@teamupdivision
Copy link
Collaborator

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.

@heshamwatany
Copy link
Author

The pagination exists in form of HTML not in laravel way of implementation

@teamupdivision
Copy link
Collaborator

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:

  1. 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();
}

  1. 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)]);
    }

  2. Now you can go to your table in resources/laravel/users/index.blade.php and add after you closing tab for
    {{ $users->links() }}

  3. 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.

@heshamwatany
Copy link
Author

It works thanks you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants