├── .gitignore
├── LICENSE
├── README.md
├── babel.config.js
├── build
└── rollup.config.js
├── package-lock.json
├── package.json
└── src
├── Footer.vue
├── Header.vue
├── Main.vue
├── assets
└── images
│ ├── sort_asc.png
│ ├── sort_asc_disabled.png
│ ├── sort_both.png
│ ├── sort_desc.png
│ └── sort_desc_disabled.png
├── composables
└── useFetch.js
├── index.js
└── table
├── Body.vue
├── General.vue
└── Header.vue
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Jhoni Larico
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
JL Datatable
2 |
3 |
A datatable server side rendering mode made with Vue JS 3 ⚙️
4 |
5 |
6 | 
7 |
8 |
9 | ## 🚀 There is an online demo:
10 |
11 | ### Front End 👉 [Repository Github](https://github.com/jhonijlm/vuejs-datatable-app)
12 |
13 | ### Backend with Laravel 👉 [Repository Github](https://github.com/jhonijlm/laravel-datatable-api)
14 |
15 |
16 | ## Basic usage
17 | ```html
18 |
35 | ```
36 |
37 | ## Installing
38 | Install the JlDatatable package:
39 | ```sh
40 | npm install jl-datatable
41 | # or
42 | yarn add jl-datatable
43 | ```
44 |
45 | Register it as you usually would:
46 | ```js
47 | import {createApp } from 'vue'
48 | import App from './App.vue'
49 |
50 | import JlDatatable from 'jl-datatable'
51 |
52 | const app = createApp(App)
53 |
54 | app.component('jl-datatable', JlDatatable)
55 |
56 | app.mount('#app')
57 | ```
58 | ### Props - General
59 |
60 | Property Name | Type | Required | Default Value | Description
61 | --- | --- | --- | --- | ---
62 | `url` | String | Yes | NULL | URL to get entries.
63 | `requestOptions` | Object | No | `{method: 'GET'}` | Allows to add more parameters in the request to be made to the server.
64 | `columns` | Array Object | Yes | `[]` | An array of objects that specifies how to render each column.
65 | `pageLength` | Integer | No | `10` | Length of records shown in the table.
66 | `lengthMenu` | Array Integer | No | `[10, 25, 50, 100]` | List of lengths for the menu to display in the table.
67 | `order` | Object | No | `{ column: 0, dir: 'ASC'}` | Sort the records, for sort you have two options of ascending (ASC) and descending (DESC) sorting.
68 | `reset` | String | No | NULL | Reset the data from the datatable. Only a random string different from the previous one should be sent.
69 |
70 |
71 | ### Prop: `columns`
72 | Property Name | Type | Required | Default Value | Description
73 | --- | --- | --- | --- | ---
74 | `label` | String | Yes | NULL | Is what is shown in the table header.
75 | `data` | String | Yes | NULL | Allows to identify the data to be obtained by means of key and value.
76 | `orderable` | Boolean | No | `True` | If true, sorting is activated for the column.
77 | `searchable` | Boolean | No | `True` | If true, the search for the column is activated.
78 | `component` | Object | No | NULL | Allows you to add a component, e.g. edit and delete buttons.
79 |
80 | ### Events
81 | Name | Return | Description
82 | --- | --- | ---
83 | `gettingEntries` | Object | Returns the request to be made to the server.
84 | `entriesFetched` | Object | Returns the request made to the server and the data.
85 | ## License
86 |
87 | MIT
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/build/rollup.config.js:
--------------------------------------------------------------------------------
1 | import vue from 'rollup-plugin-vue'
2 | import { terser } from "rollup-plugin-terser";
3 | import postcss from "rollup-plugin-postcss";
4 | import images from 'rollup-plugin-image-files';
5 |
6 | export default {
7 | input: 'src/index.js',
8 | external: [
9 | 'lodash/debounce',
10 | 'vue',
11 | 'qs',
12 | 'bootstrap/dist/css/bootstrap.min.css'
13 | ],
14 | output: {
15 | name: 'JlDatatable',
16 | exports: 'named',
17 | globals : {
18 | 'lodash/debounce': 'debounce',
19 | 'qs': 'qs',
20 | 'vue': 'vue',
21 | },
22 | },
23 | plugins: [
24 | vue({
25 | css: true,
26 | compileTemplate: true,
27 | template: {
28 | isProduction: true,
29 | },
30 | }),
31 | terser(),
32 | postcss(),
33 | images()
34 | ],
35 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jl-datatable",
3 | "description": "A datatable server side rendering mode - Vue JS 3 ⚙️",
4 | "version": "1.1.1",
5 | "private": false,
6 | "main": "dist/jl-datatable.umd.js",
7 | "module": "dist/jl-datatable.esm.js",
8 | "unpkg": "dist/jl-datatable.min.js",
9 | "browser": {
10 | "./sfc": "src/Main.vue"
11 | },
12 | "files": [
13 | "dist/*",
14 | "src/*"
15 | ],
16 | "scripts": {
17 | "lint": "vue-cli-service lint",
18 | "build": "npm run build:unpkg & npm run build:es & npm run build:umd",
19 | "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/jl-datatable.umd.js",
20 | "build:es": "rollup --config build/rollup.config.js --format es --file dist/jl-datatable.esm.js",
21 | "build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/jl-datatable.min.js"
22 | },
23 | "keywords": [
24 | "vue3",
25 | "vue",
26 | "vue-data-table",
27 | "datatable-server-side",
28 | "grid",
29 | "datatable",
30 | "pagination",
31 | "vue component"
32 | ],
33 | "repository": {
34 | "type": "git",
35 | "url": "https://github.com/jhonijlm/jl-datatable"
36 | },
37 | "bugs": {
38 | "url": "https://github.com/jhonijlm/jl-datatable/issues"
39 | },
40 | "homepage": "",
41 | "author": "Jhoni Larico ",
42 | "license": "MIT",
43 | "dependencies": {
44 | "bootstrap": "^5.1.3",
45 | "core-js": "^3.23.1",
46 | "lodash": "^4.17.21",
47 | "qs": "^6.10.5",
48 | "vue": "^3.2.37"
49 | },
50 | "devDependencies": {
51 | "@vue/cli-plugin-babel": "~5.0.6",
52 | "@vue/cli-plugin-eslint": "~5.0.6",
53 | "@vue/cli-service": "~5.0.6",
54 | "@vue/compiler-sfc": "^3.2.37",
55 | "babel-eslint": "^10.1.0",
56 | "eslint": "^8.17.0",
57 | "eslint-plugin-vue": "^9.1.1",
58 | "rollup": "^2.75.6",
59 | "rollup-plugin-image-files": "^1.4.2",
60 | "rollup-plugin-postcss": "^4.0.2",
61 | "rollup-plugin-terser": "^7.0.2",
62 | "rollup-plugin-vue": "^6.0.0"
63 | },
64 | "eslintConfig": {
65 | "root": true,
66 | "env": {
67 | "node": true
68 | },
69 | "extends": [
70 | "plugin:vue/vue3-essential",
71 | "eslint:recommended"
72 | ],
73 | "parserOptions": {
74 | "parser": "babel-eslint"
75 | },
76 | "rules": {}
77 | },
78 | "browserslist": [
79 | "> 1%",
80 | "last 2 versions",
81 | "not dead"
82 | ]
83 | }
84 |
--------------------------------------------------------------------------------
/src/Footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Showing {{ startF }} to {{ toF }} of {{ recordsFiltered }} entries {{ filteredStr }}