lara-vue-datatable

Laravel and Vuejs based custom datatable with pagination, search and page length
435
Install
npm install lara-vue-datatable
Latest Version:0.0.18
Vue:2
License:MIT
Last Updated:Sep 13, 2021
Links: GitHub  ·  npm
Maintainer: sandeshsatyal

Laravel Vue Datatable

A Vuejs datatable with search and pagination component for Laravel paginators that works with almost all frameworks.

Requirements

  • Vuejs 2.x +
  • Laravel 5.x +

Install

    npm install lara-vue-datatable

Usage

    import {DataTable, TableLength, Pagination, Search, TableStore} from "lara-vue-datatable";

   <TableLength :options="tableLength"/>
          <search></search>
          <data-table
              :url="'http://neomeet.local/api/users'"
              :columns="columns"
              :dbcolumns="dbcolumns"
              :styles="'table-striped table-responsive'"
              :buttons="[
            {
              label: 'Edit',
              class: 'btn btn-success btn-sm',
              action: 'edit'
            },{
              label: 'Delete',
              class: 'btn btn-danger btn-sm',
              action: 'delete'
            },

        ]"
          >
          </data-table>

          <Pagination/>

        export default {
            components: {
                TableLength,
                Pagination,
                SandeshVueTable,
                Search,
                TableStore
            },
            data() {
                return {
                    tableLength: {
                        default: 3,
                        lengths: [1,2,3,4,5],
                    },
                    columns: ['Name','Slug','Phone','Email'],
                    dbcolumns: ['name','slug','phone','email'],
                }
            },
            methods: {
               edit(data) {
                  prompt('Editing ' + data.name);
              },
        
              destroy(data) {
                  alert('Are you sure you want to delete ' + data.name + 'from system ?' );
              },
            }

             computed: {
                  action() {
                    return TableStore.getters.getAction;
                  }
            },

            watch: {
                  action() {
                      if (this.action.method === 'delete') {
                          this.destroy(this.action.data);
                      } else if (this.action.method === 'edit') {
                          this.edit(this.action.data);
                      }
                  }
            },
        }

Laravel Method Example

    public function getUsers()
    {
        $length = request('per_page')??5;
        $search = request('searchText') ?? request('searchText');
        return User::where('name','like', '%'.$search.'%')->paginate($length);
    }

Development

To work on the library locally, run the following command:

    npm run dev

This will boot development server with Test component

Credits

Laravel Vue Pagination is created by Sandesh Satyal from NeoDigital Nepal Pvt Ltd. Released under the MIT license.

Keywords

Vue Vuejs component laravel datatable pagination

Related Packages

@jobinsjp/vue3-datatable

DataTable component with basic pagination, search filters etc for Vue3

8,888 110
advanced-laravel-vue-paginate

A advanced, smart, highly customizable vue pagination component for Laravel pagi...

1,198 4
@jagjerez/vue3-datatable

DataTable component with basic pagination, search filters etc for Vue3

939 110
laravel-vue-pagination

Vue.js pagination component for Laravel paginators

593,998 745
vue-bootstrap-pagination

Pagination for vuejs with combination with bootstrap and Laravel's pagination

6,577 99

Version History

Version Released Vue License
0.0.18 ^2.6.14 MIT
0.0.17 ^2.6.14 MIT
0.0.16 ^2.6.14 MIT
0.0.15 ^2.6.14 MIT
0.0.14 ^2.6.14 MIT