data fetch in limit from backend on click of pagination number.

data fetch in limit from backend on click of pagination number.

sameer123sameer123 Posts: 2Questions: 2Answers: 0
edited May 23 in Free community support

I am using vue js with laravel as a backend.
I fetch users with limit 10.
and i am using datatable -

import DataTable from 'datatables.net-vue3';
import DataTableLib from 'datatables.net-bs5';
import 'datatables.net-responsive-bs5';

DataTable.use(DataTableLib);

export default {
      components: {DataTable},
      data() {
          return {
              users: null,
              columns: [
                  {data: null, render: function(data,type,row,meta){
                      return `${meta.row + 1}`
                  }},
                  {data: 'name'},
                  {data: 'email'},
                  {data: null, render: function(data,type,row,meta)
                      {
                          return data.status;
                      }}
              ],

            options: {
                responsive: true,
                autoWidth: false,
                // dom: 'Bfrtip',
                language: {
                    // search: 'Search',
                    searchPlaceholder: 'Type In To Search',
                    zeroRecords: 'No Data available'
                }
            }

          }
      },
      mounted() {
          this.getUsers();
      },
      methods: {
          getUsers() {
              axios.post(this.route('user'), {})
              .then((response) => {
                  this.users = response.data.data
              })
          }
      }
  }

but how to draw or hit again api for others data on second page, third page and so on ?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,434Questions: 1Answers: 10,458 Site admin

    What you are describing is what we call server-side processing in DataTables terminology.

    If you want to use server-side processing you'll need a server-side script that implements the protocol described here.

    Only if you have tens of thousands or more rows in it is it worth doing server-side processing. Otherwise, just use client-side processing.

    Allan

    Allan

Sign In or Register to comment.