@sulzanoks/vue-datatable 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -0
- package/dist/datatable-card.es.js +4548 -0
- package/dist/datatable-card.umd.js +11 -0
- package/dist/style.css +1 -0
- package/dist/vite.svg +1 -0
- package/package.json +34 -0
- package/src/Components/DatatableCard.vue +780 -0
- package/src/Images/sort_asc.png +0 -0
- package/src/Images/sort_asc_disabled.png +0 -0
- package/src/Images/sort_both.png +0 -0
- package/src/Images/sort_desc.png +0 -0
- package/src/Images/sort_desc_disabled.png +0 -0
- package/src/Sass/Style.scss +552 -0
- package/src/Sass/partials/_card_header.scss +59 -0
- package/src/index.js +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# DatatableCard Component
|
|
2
|
+
|
|
3
|
+
DatatableCard is a custom Vue.js component designed to provide a flexible and customizable datatable for your web applications. It is built from scratch, inspired by the Bootstrap datatable, but with added features to support Vue.js style links and row selection.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install the DatatableCard component using npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @sulzanoks/vue-datatable
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
To use the DatatableCard component in your Vue.js application, you can import it and include it in your component's template. Here's an example of how to use it:
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<datatable-card
|
|
21
|
+
:card-title="cardTitle"
|
|
22
|
+
:columns="columns"
|
|
23
|
+
:url="dataUrl"
|
|
24
|
+
>
|
|
25
|
+
</datatable-card>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import DatatableCard from '@sulzanoks/vue-datatable';
|
|
31
|
+
import '@sulzanoks/vue-datatable/dist/style.css';
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
components: {
|
|
35
|
+
DatatableCard,
|
|
36
|
+
},
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
cardTitle: 'My Datatable',
|
|
40
|
+
columns: [
|
|
41
|
+
// Define your datatable columns here
|
|
42
|
+
// Example: { data: 'id', name: 'ID', sortable: true, searchable: true }
|
|
43
|
+
],
|
|
44
|
+
dataUrl: '/api/data', // Replace with your data endpoint URL
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Props
|
|
52
|
+
|
|
53
|
+
The DatatableCard component accepts the following props:
|
|
54
|
+
|
|
55
|
+
- `cardTitle` (String): The title for the datatable card.
|
|
56
|
+
- `columns` (Array): An array of column objects defining the datatable columns.
|
|
57
|
+
- `data` (String): The key to access the data for this column in the API response.
|
|
58
|
+
- `displayName` (String): The display name or label for this column.
|
|
59
|
+
- `name` (String): The unique name or identifier for this column.
|
|
60
|
+
- `searchable` (Boolean, optional, default: true): Set to `false` to disable searching for this column.
|
|
61
|
+
- `sortable` (Boolean, optional, default: true): Set to `false` to disable sorting for this column.
|
|
62
|
+
- `linkParams` (Object, optional): Defines link parameters for generating Vue.js style links.
|
|
63
|
+
- `name` (String): The name of the Vue.js route to navigate to when clicking the link.
|
|
64
|
+
- `resourceIds` (Array): An array of resource IDs to use in generating the link. Replace with actual resource IDs.
|
|
65
|
+
- `url` (String): The URL for fetching datatable data.
|
|
66
|
+
- `selectableRows` (Boolean): Set to `true` to enable row selection. For now only works if you have a, `id` column in your data set.
|
|
67
|
+
- `order` (Array): The initial column sorting order. example: `[{ column: 0, dir: 'asc' }]`
|
|
68
|
+
- `advancedSearch` (Boolean): Set to `true` to enable advanced search, which generates an individual search input for each searchable column.
|
|
69
|
+
- `loadDataOnInit` (Boolean): Set to `true` to load data when the component is initialized.
|
|
70
|
+
- `cardIconStyle` (String, optional, default: 'card-header-primary'. There are no other options): The CSS class to apply to the card's header for icon styling.
|
|
71
|
+
- `cardIcon` (String, optional, default: null): The name of an icon from [Google Icons](https://fonts.google.com/icons) to display in the card's header. Provide the icon name without any additional markup, such as `<i>` tags. For example, if you want to use the "account_circle" icon, set this prop to `'account_circle'`. If not specified, no icon will be displayed in the card's header.
|
|
72
|
+
- `cardClasses` (String, optional, default: null): Additional CSS classes to apply to the card.
|
|
73
|
+
- `createLink` (String, optional, default: null): A link or URL to navigate to when clicking a "Create" button or link within the card.
|
|
74
|
+
|
|
75
|
+
## Internal Methods
|
|
76
|
+
|
|
77
|
+
These methods are meant to be used by component internally, but maybe you can find use for them
|
|
78
|
+
|
|
79
|
+
- `toggleSearch()`: Toggle the search input.
|
|
80
|
+
- `clearSearch()`: Clear the search bar and reload data.
|
|
81
|
+
- `setAdvancedSearchFilters()`: Set advanced search filters based in input element values and reload data.
|
|
82
|
+
- `loadData()`: Load datatable data.
|
|
83
|
+
- `initColumnSettings()`: Initialize column settings.
|
|
84
|
+
- `setPageLength(length)`: Set the number of rows per page and reload data.
|
|
85
|
+
- `setPage(page)`: Set the current page and reload data.
|
|
86
|
+
- `setSearchTerm()`: Set the full text search term for basic search on all columns and reload data.
|
|
87
|
+
- `setSorting(index)`: Set the sorting order for a column and reload data.
|
|
88
|
+
- `generateLink(linkParams, row)`: Generate a link based on parameters and row data.
|
|
89
|
+
- `selectAllRows()`: Select or deselect all rows.
|
|
90
|
+
- `clearSelectedRows()`: Clear the selected rows.
|
|
91
|
+
|
|
92
|
+
## Methods
|
|
93
|
+
- `getSelectedRows()`: Returns array of selected rows
|
|
94
|
+
- `filterColumns(params)`: Filter columns based on parameters and reload data.
|
|
95
|
+
```javascript
|
|
96
|
+
this.$refs.myDataTable.filterColumns([
|
|
97
|
+
{
|
|
98
|
+
name: 'serial_number',
|
|
99
|
+
value: this.uniqueId,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'product_name',
|
|
103
|
+
value: this.productName,
|
|
104
|
+
}
|
|
105
|
+
]);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Compatibility
|
|
109
|
+
|
|
110
|
+
This component is designed to work with Laravel's [`yajra/laravel-datatables-oracle`](https://yajrabox.com/docs/laravel-datatables). It may work with other packages that use a similar input/output structure, but it has not been tested extensively with other packages.
|
|
111
|
+
|
|
112
|
+
Please make sure that your Laravel backend and the API endpoints are configured to work with this component.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
This DatatableCard component is open-source software licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
|