@sulzanoks/vue-datatable 0.3.6 → 0.4.1

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 CHANGED
@@ -1,29 +1,39 @@
1
- # DatatableCard Component
1
+ # Vue DatatableCard
2
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.
3
+ `DatatableCard` is a server-side Vue 3 datatable component designed for Laravel applications using a DataTables-compatible backend, such as [`yajra/laravel-datatables-oracle`](https://yajrabox.com/docs/laravel-datatables).
4
4
 
5
- ## Installation
5
+ It supports server-side pagination, sorting, global and per-column search, row selection, clickable rows, custom row actions, localized interface text, Inertia or native links, custom cell rendering, and conditional cell classes.
6
+
7
+ ## Requirements
8
+
9
+ - Vue 3
10
+ - Axios
11
+ - `@inertiajs/vue3`
12
+ - A server endpoint that accepts DataTables-style query parameters and returns a compatible response
6
13
 
7
- You can install the DatatableCard component using npm:
14
+ The component also uses Bootstrap/Material-style classes and Material Icons in its default markup.
15
+
16
+ ## Installation
8
17
 
9
18
  ```bash
10
19
  npm install @sulzanoks/vue-datatable
11
20
  ```
12
21
 
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:
22
+ ## Basic usage
16
23
 
17
24
  ```vue
18
25
  <template>
19
- <div>
20
- <datatable-card
21
- :card-title="cardTitle"
22
- :columns="columns"
23
- :url="dataUrl"
24
- >
25
- </datatable-card>
26
- </div>
26
+ <DatatableCard
27
+ ref="datatable"
28
+ card-title="Users"
29
+ card-icon="people"
30
+ url="/users/datatable"
31
+ :columns="columns"
32
+ :order="[{ column: 0, dir: 'asc' }]"
33
+ :page-length="25"
34
+ clickable-rows
35
+ @row-click="openUser"
36
+ />
27
37
  </template>
28
38
 
29
39
  <script>
@@ -31,169 +41,507 @@ import DatatableCard from '@sulzanoks/vue-datatable';
31
41
  import '@sulzanoks/vue-datatable/dist/style.css';
32
42
 
33
43
  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
- },
44
+ components: {
45
+ DatatableCard,
46
+ },
47
+
48
+ data() {
49
+ return {
50
+ columns: [
51
+ {
52
+ data: 'id',
53
+ name: 'users.id',
54
+ displayName: 'ID',
55
+ searchable: false,
56
+ width: '80px',
57
+ },
58
+ {
59
+ data: 'name',
60
+ name: 'users.name',
61
+ displayName: 'Name',
62
+ link: row => `/users/${row.id}`,
63
+ },
64
+ {
65
+ data: 'email',
66
+ name: 'users.email',
67
+ displayName: 'Email',
68
+ },
69
+ ],
70
+ };
71
+ },
72
+
73
+ methods: {
74
+ openUser(row) {
75
+ window.location.href = `/users/${row.id}`;
76
+ },
77
+ },
47
78
  };
48
79
  </script>
49
80
  ```
50
81
 
51
82
  ## Props
52
83
 
53
- The DatatableCard component accepts the following props:
54
-
55
- - `cardTitle` (String): The title for the datatable card.
56
- - `clickable-rows` (Boolean, optional, default: false): Set to true to enable `row-click` event.
57
- - `columns` (Array): An array of column objects defining the datatable columns.
58
- - `data` (String): The key to access the data for this column in the API response.
59
- - `displayName` (String): The display name or label for this column.
60
- - `name` (String): The unique name or identifier for this column.
61
- - `searchable` (Boolean, optional, default: true): Set to `false` to disable searching for this column.
62
- - `sortable` (Boolean, optional, default: true): Set to `false` to disable sorting for this column.
63
- - `visible` (Boolean, optional, default: true): Set to `false` to remove column from table.
64
- - `width` (String, optional): Set solumn to width specified css param.
65
- - `linkParams` (Object, optional): Defines link parameters for generating Vue.js style links.
66
- - `name` (String): The name of the Vue.js route to navigate to when clicking the link.
67
- - `resourceIds` (Array): An array of resource IDs to use in generating the link. Replace with actual resource IDs.
68
- - `query` (Object, optional): object of attributes to include in link query params
69
- - `url` (String): The URL for fetching datatable data.
70
- - `selectableRows` (Boolean): Set to `true` to enable row selection. For now only works if you have a, `id` column in your data set.
71
- - `order` (Array): The initial column sorting order. example: `[{ column: 0, dir: 'asc' }]`
72
- - `advancedSearch` (Boolean): Set to `true` to enable advanced search, which generates an individual search input for each searchable column.
73
- - `loadDataOnInit` (Boolean): Set to `true` to load data when the component is initialized.
74
- - `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.
75
- - `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.
76
- - `cardClasses` (String, optional, default: null): Additional CSS classes to apply to the card.
77
- - `createLink` (String, optional, default: null): A link or URL to navigate to when clicking a "Create" button or link within the card.
78
- - `requestQueryParams` (Object, optional): additional request query parameters to include when loading data from server.
79
- - `actions` (Array, optional): Array of action objects defining action buttons for each row.
80
- - `emit` (String, required): name of event to emit upon click
81
- - `icon` (String, optional): The name of an icon from [Google Icons](https://fonts.google.com/icons) to display inside button.
82
- - `label` (String, optional): Text to display inside button.
83
- - `class` (String, optional): CSS class to apply to button.
84
-
85
- ## Link Parameters (`linkParams`)
86
-
87
- The `generateLink` method now supports **two modes** for building links:
88
-
89
- ### 1. Laravel Route Name (default / original behavior)
90
-
91
- Use when you want to leverage Laravel named routes via Ziggy’s `route()` helper.
84
+ | Prop | Type | Default | Description |
85
+ |---|---|---:|---|
86
+ | `url` | `String` | required | Server endpoint used to load table data. |
87
+ | `columns` | `Array` | required | Column definitions. See [Column configuration](#column-configuration). |
88
+ | `locale` | `String` | `'en'` | Locale used for built-in interface text. |
89
+ | `vocabulary` | `Object` | `{}` | Custom translations grouped by locale. |
90
+ | `cardTitle` | `String` | `null` | Card title. |
91
+ | `cardIcon` | `String` | `null` | Material Icon name displayed in the header. |
92
+ | `cardIconStyle` | `String` | `'card-header-primary'` | CSS class applied to the icon header when there is no error. |
93
+ | `cardClasses` | `String` | `null` | Additional classes applied to the root card. |
94
+ | `createLink` | `String` | `null` | URL used by the header create button. It is rendered as an Inertia `<Link>`. |
95
+ | `selectableRows` | `Boolean` | `false` | Enables row checkboxes. Rows must contain an `id` value. |
96
+ | `order` | `Array` | `[{ column: 0, dir: 'asc' }]` | Initial DataTables sorting configuration. |
97
+ | `advancedSearch` | `Boolean` | `false` | Enables one search field for every searchable column. |
98
+ | `loadDataOnInit` | `Boolean` | `true` | Loads data when the component mounts. |
99
+ | `requestQueryParams` | `Object` | `{}` | Extra query parameters included with every server request. |
100
+ | `actions` | `Array` | `undefined` | Row action button definitions. |
101
+ | `clickableRows` | `Boolean` | `false` | Emits `row-click` when a table row is clicked. |
102
+ | `hyperlinkStyle` | `String` | `'Link'` | Controls column link rendering. Supported values are `'Link'` and `'a'`. |
103
+ | `pageLength` | `Number` | `10` | Initial number of rows per page. |
104
+ | `showHeader` | `Boolean` | `true` | To hide default header controls, set to `false`. |
105
+
106
+ In templates, camelCase props can be passed using kebab-case, for example `page-length`, `clickable-rows`, and `request-query-params`.
107
+
108
+ ## Column configuration
109
+
110
+ Each entry in `columns` supports the following properties:
111
+
112
+ | Property | Type | Default | Description |
113
+ |---|---|---:|---|
114
+ | `data` | `String` | required | Row property displayed in the cell and sent as the DataTables column `data` value. |
115
+ | `name` | `String` | recommended | Server-side column name. Required for advanced search and normally used by the backend for filtering and sorting. |
116
+ | `displayName` | `String` | required | Column heading and advanced-search placeholder. |
117
+ | `searchable` | `Boolean` | `true` | Set to `false` to disable searching for the column. |
118
+ | `sortable` | `Boolean` | `true` | Set to `false` to disable sorting for the column. |
119
+ | `visible` | `Boolean` | `true` | Set to `false` to hide the column while keeping it in the request configuration. |
120
+ | `width` | `String` | — | CSS width applied to the heading, such as `'120px'` or `'20%'`. |
121
+ | `link` | `Function` | — | Receives the current row and returns the destination URL. |
122
+ | `render` | `Function` | — | Receives the current row and returns HTML rendered with `v-html`. |
123
+ | `classes` | `String \| Array` | — | Static classes or conditional numeric class rules for the table cell. |
124
+
125
+ ### Column links
126
+
127
+ Define `link` as a function that receives the current row:
92
128
 
93
129
  ```js
94
130
  {
95
- data: 'title',
96
- linkParams: {
97
- name: 'users.show', // Laravel route name
98
- resourceIds: ['id'], // values taken from the row
99
- query: { tab: 'info' } // optional query params
100
- }
131
+ data: 'name',
132
+ name: 'users.name',
133
+ displayName: 'Name',
134
+ link: row => `/users/${row.id}`,
101
135
  }
102
136
  ```
103
137
 
104
- ➡️ If `row.id = 5`, this builds:
138
+ By default, links use Inertia's `<Link>` component:
139
+
140
+ ```vue
141
+ <DatatableCard hyperlink-style="Link" />
142
+ ```
143
+
144
+ Use a native anchor instead when a full browser navigation or download is required:
145
+
146
+ ```vue
147
+ <DatatableCard hyperlink-style="a" />
105
148
  ```
106
- /users/5?tab=info
149
+
150
+ The previous `linkParams` and Ziggy-based `generateLink()` API is no longer supported. Generate the URL in the `link(row)` callback or return a ready-to-use URL from the backend:
151
+
152
+ ```js
153
+ {
154
+ data: 'invoice_number',
155
+ name: 'invoices.invoice_number',
156
+ displayName: 'Invoice',
157
+ link: row => row.url,
158
+ }
107
159
  ```
108
160
 
109
- ### 2. Link Template
161
+ ### Custom cell rendering
110
162
 
111
- Use when you want full control over the URL structure without relying on Laravel route names.
163
+ Use `render(row)` to return custom HTML:
112
164
 
113
- #### Object Form
114
165
  ```js
115
166
  {
116
- data: 'title',
117
- linkParams: {
118
- template: '/users/{id}/posts/{post_id}',
119
- params: { post_id: 'latest' }, // override or add interpolation values
120
- query: { filter: 'active' } // optional query params
121
- }
167
+ data: 'status',
168
+ name: 'status',
169
+ displayName: 'Status',
170
+ render: row => `<span class="badge bg-success">${row.status}</span>`,
122
171
  }
123
172
  ```
124
- ➡️ If `row.id = 5`, this builds:
173
+
174
+ `render()` output is inserted using `v-html`. Only return trusted or sanitized HTML. When `render` is defined, it takes precedence over `link` and the normal text value.
175
+
176
+ ### Static cell classes
177
+
178
+ ```js
179
+ {
180
+ data: 'total',
181
+ name: 'total',
182
+ displayName: 'Total',
183
+ classes: 'text-end fw-bold',
184
+ }
125
185
  ```
126
- /users/5/posts/latest?filter=active
186
+
187
+ ### Conditional cell classes
188
+
189
+ `classes` can also be an array of numeric rules. The `min` and `max` limits are inclusive.
190
+
191
+ ```js
192
+ {
193
+ data: 'difference',
194
+ name: 'difference',
195
+ displayName: 'Difference',
196
+ classes: [
197
+ { max: -0.01, class: 'text-danger' },
198
+ { min: 0, max: 0, class: 'text-muted' },
199
+ { min: 0.01, class: 'text-success' },
200
+ ],
201
+ }
127
202
  ```
128
203
 
129
- #### String Shorthand
204
+ Use `valueKey` to evaluate another row property:
205
+
130
206
  ```js
131
207
  {
132
- data: 'title',
133
- linkParams: '/users/{id}'
208
+ data: 'hourly_rate',
209
+ name: 'hourly_rate',
210
+ displayName: 'Hourly rate',
211
+ classes: [
212
+ {
213
+ valueKey: 'rate_difference',
214
+ max: -0.01,
215
+ class: 'bg-danger-subtle',
216
+ },
217
+ ],
134
218
  }
135
219
  ```
136
- ➡️ If `row.id = 5`, this builds:
220
+
221
+ String values are parsed as numbers, and a trailing percent sign is ignored during parsing.
222
+
223
+ ## Localization
224
+
225
+ The component translates its interface using the `locale` and `vocabulary` props.
226
+
227
+ ```vue
228
+ <DatatableCard
229
+ locale="lv"
230
+ :vocabulary="vocabulary"
231
+ :columns="columns"
232
+ url="/users/datatable"
233
+ />
137
234
  ```
138
- /users/5
235
+
236
+ ```js
237
+ export default {
238
+ data() {
239
+ return {
240
+ vocabulary: {
241
+ lv: {
242
+ search: 'Meklēt',
243
+ close: 'Aizvērt',
244
+ createNew: 'Izveidot',
245
+ showEntries: 'Rādīt ierakstu skaitu',
246
+ actions: 'Darbības',
247
+ showingRecords: 'Rāda {first}. līdz {last}. no {filtered} ierakstiem',
248
+ totalRecords: 'kopā {total} ieraksti',
249
+ first: 'Pirmā',
250
+ previous: 'Iepriekšējā',
251
+ next: 'Nākamā',
252
+ last: 'Pēdējā',
253
+ loadingError: 'Neizdevās ielādēt datus',
254
+ },
255
+ },
256
+ };
257
+ },
258
+ };
139
259
  ```
140
260
 
141
- ### Template Placeholders
261
+ ### Translation keys
142
262
 
143
- Templates support both styles:
144
- - `{key}` → `/users/{id}`
145
- - `:key` → `/users/:id`
263
+ | Key | Used for |
264
+ |---|---|
265
+ | `search` | Search placeholder, search button, and tooltip |
266
+ | `close` | Close-search tooltip |
267
+ | `createNew` | Create-link tooltip |
268
+ | `showEntries` | Page-length menu tooltip |
269
+ | `actions` | Row actions column heading |
270
+ | `showingRecords` | Record-range text; supports `{first}`, `{last}`, and `{filtered}` |
271
+ | `totalRecords` | Unfiltered total; supports `{total}` |
272
+ | `first` | First-page button |
273
+ | `previous` | Previous-page button |
274
+ | `next` | Next-page button |
275
+ | `last` | Last-page button |
276
+ | `loadingError` | Generic data-loading error |
146
277
 
147
- Both will be replaced with the row’s value (or overridden via `params`).
278
+ Translation lookup order is:
148
279
 
149
- ### Notes
150
- - If both `params` and row values define the same key, `params` takes precedence.
151
- - Query parameters (`query`) are supported in both modes.
152
- - If you just need a simple route name, use **mode 1**; if you want custom URLs, use **mode 2**.
280
+ 1. `vocabulary[locale][key]`
281
+ 2. `vocabulary.en[key]`
282
+ 3. package defaults for the selected locale
283
+ 4. package English default
284
+ 5. the translation key itself
153
285
 
154
- ## Internal Methods
286
+ The locale key must match the `locale` prop exactly.
155
287
 
156
- These methods are meant to be used by component internally, but maybe you can find use for them
288
+ ## Advanced search
157
289
 
158
- - `toggleSearch()`: Toggle the search input.
159
- - `clearSearch()`: Clear the search bar and reload data.
160
- - `setAdvancedSearchFilters()`: Set advanced search filters based in input element values and reload data.
161
- - `loadData()`: Load datatable data.
162
- - `initColumnSettings()`: Initialize column settings.
163
- - `setPageLength(length)`: Set the number of rows per page and reload data.
164
- - `setPage(page)`: Set the current page and reload data.
165
- - `setSearchTerm()`: Set the full text search term for basic search on all columns and reload data.
166
- - `setSorting(index)`: Set the sorting order for a column and reload data.
167
- - `generateLink(linkParams, row)`: Generate a link based on parameters and row data.
168
- - `selectAllRows()`: Select or deselect all rows.
169
- - `clearSelectedRows()`: Clear the selected rows.
290
+ Enable per-column inputs with:
170
291
 
171
- ## Methods
172
- - `getSelectedRows()`: Returns array of selected rows
173
- - `filterColumns(params)`: Filter columns based on parameters and reload data.
174
- ```javascript
175
- this.$refs.myDataTable.filterColumns([
176
- {
177
- name: 'serial_number',
178
- value: this.uniqueId,
292
+ ```vue
293
+ <DatatableCard advanced-search />
294
+ ```
295
+
296
+ An input is generated for each column where `searchable !== false`. Each searchable column should have a unique `name` value.
297
+
298
+ The search toolbar is opened and closed with the header search icon. Submitting the form resets pagination to the first page and reloads the data.
299
+
300
+ ## Global search
301
+
302
+ When `advancedSearch` is disabled, the component displays a global search field. Input is debounced by 500 milliseconds before a new request is sent.
303
+
304
+ ## Row selection
305
+
306
+ ```vue
307
+ <DatatableCard
308
+ ref="datatable"
309
+ selectable-rows
310
+ :columns="columns"
311
+ url="/users/datatable"
312
+ />
313
+ ```
314
+
315
+ Rows must include an `id` property. Selection applies to the currently loaded page and is cleared whenever data is reloaded.
316
+
317
+ Read the selected IDs through the public method:
318
+
319
+ ```js
320
+ const selectedIds = this.$refs.datatable.getSelectedRows();
321
+ ```
322
+
323
+ ## Clickable rows
324
+
325
+ ```vue
326
+ <DatatableCard
327
+ clickable-rows
328
+ @row-click="handleRowClick"
329
+ />
330
+ ```
331
+
332
+ ```js
333
+ methods: {
334
+ handleRowClick(row) {
335
+ console.log(row);
336
+ },
337
+ }
338
+ ```
339
+
340
+ Clicks on selection checkboxes, column links, and action buttons do not trigger `row-click`.
341
+
342
+ ## Row actions
343
+
344
+ Define one or more buttons using the `actions` prop:
345
+
346
+ ```vue
347
+ <DatatableCard
348
+ :columns="columns"
349
+ :actions="actions"
350
+ url="/users/datatable"
351
+ @edit="editUser"
352
+ @remove="removeUser"
353
+ />
354
+ ```
355
+
356
+ ```js
357
+ export default {
358
+ data() {
359
+ return {
360
+ actions: [
361
+ {
362
+ emit: 'edit',
363
+ icon: 'edit',
364
+ label: 'Edit',
365
+ class: 'btn-primary',
366
+ },
367
+ {
368
+ emit: 'remove',
369
+ icon: 'delete',
370
+ label: 'Delete',
371
+ class: 'btn-danger',
372
+ },
373
+ ],
374
+ };
375
+ },
376
+
377
+ methods: {
378
+ editUser(row) {
379
+ // Handle edit action
179
380
  },
180
- {
181
- name: 'product_name',
182
- value: this.productName,
183
- }
184
- ]);
381
+
382
+ removeUser(row) {
383
+ // Handle remove action
384
+ },
385
+ },
386
+ };
387
+ ```
388
+
389
+ Each action supports:
390
+
391
+ | Property | Type | Description |
392
+ |---|---|---|
393
+ | `emit` | `String` | Event name emitted with the current row as its payload. |
394
+ | `icon` | `String` | Optional Material Icon name. |
395
+ | `label` | `String` | Optional button label. |
396
+ | `class` | `String \| Object \| Array` | Classes passed to the button's Vue `:class` binding. |
397
+
398
+ The actions column is only rendered when the array contains at least one item.
399
+
400
+ ## Extra request parameters
401
+
402
+ Use `requestQueryParams` to append application-specific filters:
403
+
404
+ ```vue
405
+ <DatatableCard
406
+ :request-query-params="{
407
+ organization_id: organizationId,
408
+ active: 1,
409
+ }"
410
+ />
411
+ ```
412
+
413
+ These values are merged into the same Axios request as the DataTables parameters.
414
+
415
+ ## Slots
416
+
417
+ ### `header`
418
+
419
+ Adds custom content at the beginning of the card header. The built-in icon, title, error text, and controls are still rendered.
420
+
421
+ ```vue
422
+ <DatatableCard>
423
+ <template #header>
424
+ <span class="text-muted">Updated moments ago</span>
425
+ </template>
426
+ </DatatableCard>
427
+ ```
428
+
429
+ ### `actions`
430
+
431
+ Adds custom controls before the built-in create, search, and page-length controls.
432
+
433
+ ```vue
434
+ <DatatableCard>
435
+ <template #actions>
436
+ <li>
437
+ <button type="button" @click="exportRows">Export</button>
438
+ </li>
439
+ </template>
440
+ </DatatableCard>
441
+ ```
442
+
443
+ ### Default slot
444
+
445
+ Adds content inside the card body above the search toolbar and table.
446
+
447
+ ```vue
448
+ <DatatableCard>
449
+ <div class="alert alert-info">
450
+ Select a row to view details.
451
+ </div>
452
+ </DatatableCard>
453
+ ```
454
+
455
+ ## Public methods
456
+
457
+ Assign a template ref before calling public methods:
458
+
459
+ ```vue
460
+ <DatatableCard ref="datatable" />
461
+ ```
462
+
463
+ ### `refresh()`
464
+
465
+ Resets sorting, filters, pagination, selection, and search inputs. When `loadDataOnInit` is `true`, it reloads data; otherwise it clears the rows.
466
+
467
+ ```js
468
+ this.$refs.datatable.refresh();
469
+ ```
470
+
471
+ ### `filterColumns(params)`
472
+
473
+ Sets server-side search values for named columns, resets pagination, and reloads data.
474
+
475
+ ```js
476
+ this.$refs.datatable.filterColumns([
477
+ {
478
+ name: 'serial_number',
479
+ value: this.uniqueId,
480
+ },
481
+ {
482
+ name: 'product_name',
483
+ value: this.productName,
484
+ },
485
+ ]);
486
+ ```
487
+
488
+ Columns not included in `params` have their current search value cleared.
489
+
490
+ ### `getSelectedRows()`
491
+
492
+ Returns the selected row IDs from the currently loaded page:
493
+
494
+ ```js
495
+ const selectedIds = this.$refs.datatable.getSelectedRows();
185
496
  ```
186
- - `refresh()`: Clears all sorting and filters, reloads or clears data based on `loadDataOnInit` prop.
187
497
 
188
498
  ## Events
189
- - `row-click`: Emitted when row is click if `clickable-rows` prop is set to true. The event payload contains the clicked row data.
499
+
500
+ | Event | Payload | Description |
501
+ |---|---|---|
502
+ | `row-click` | Current row object | Emitted when `clickableRows` is enabled and the user clicks a row. |
503
+ | Action-defined event | Current row object | Emitted when a configured row action is clicked. The event name comes from `action.emit`. |
504
+
505
+ ## Server-side API
506
+
507
+ The component sends DataTables-style parameters through an Axios `GET` request, including:
508
+
509
+ - `draw`
510
+ - `columns`
511
+ - `order`
512
+ - `start`
513
+ - `length`
514
+ - `search`
515
+ - values from `requestQueryParams`
516
+
517
+ The endpoint should return at least:
518
+
519
+ ```json
520
+ {
521
+ "data": [],
522
+ "recordsTotal": 0,
523
+ "recordsFiltered": 0
524
+ }
525
+ ```
526
+
527
+ The component also recognizes an `error` field in a successful response:
528
+
529
+ ```json
530
+ {
531
+ "error": "Unable to load records"
532
+ }
533
+ ```
534
+
535
+ When an Axios request fails, the component displays the response message when available, otherwise it uses the localized `loadingError` text.
190
536
 
191
537
  ## Compatibility
192
538
 
193
- 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.
539
+ The component is designed for Laravel endpoints powered by [`yajra/laravel-datatables-oracle`](https://yajrabox.com/docs/laravel-datatables), but it can work with any backend that accepts and returns the same request/response structure.
540
+
541
+ ## Security
194
542
 
195
- Please make sure that your Laravel backend and the API endpoints are configured to work with this component.
543
+ The `render(row)` column callback uses Vue's `v-html`. Never insert unsanitized user-controlled content through `render()`.
196
544
 
197
545
  ## License
198
546
 
199
- This DatatableCard component is open-source software licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
547
+ This project is open-source software licensed under the MIT License. See [LICENSE](LICENSE) for details.