Skip to content

Commit 70de32b

Browse files
authored
Merge pull request #28 from coolsam726/coolsam726-patch-1
Datatables Help Guide CLOSES #26
2 parents af328fc + 2cffd60 commit 70de32b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,50 @@ The generated vue files are placed under the Pages/Books folder in the js folder
225225
Then the menu for payments must have `payments` as the json key.
226226
- For parent menus and any other menus which may not match any module, you have to create a permission with the key name to control its access. For example, if you have a parent menu called `master-data` you have to generate a permission with the same name.
227227

228+
## Components Documentation
229+
### Datatables
230+
JIG is built on top of datatables.net and is fully server-side rendered using [Yajra Datatables](https://yajrabox.com/docs/laravel-datatables/master/introduction). Most of the logic resides inside `App\Repositories` and in the respective Repository file, there is a method called `dtColumns` which is used to fully control the columns shown in the Index page.
231+
232+
For example, in order to control the columns shown for the Users Datatable, the following is the `dtColumns` method under `App\Repositories\Users.php`:
233+
```php
234+
public static function dtColumns(): array
235+
{
236+
return [
237+
Column::make('id')->title('ID')->className('all text-right'),
238+
Column::make("name")->className('all'),
239+
Column::make("first_name")->className('none'),
240+
Column::make("last_name")->className('none'),
241+
Column::make("middle_name")->className('none'),
242+
Column::make("username")->className('min-desktop-lg'),
243+
Column::make("email")->className('min-desktop-lg'),
244+
Column::make("gender")->className('min-desktop-lg'),
245+
Column::make("dob")->className('none'),
246+
//Column::make("email_verified_at")->className('min-desktop-lg'),
247+
Column::make("activated")->className('min-desktop-lg'),
248+
Column::make("created_at")->className('min-tv'),
249+
Column::make("updated_at")->className('min-tv'),
250+
Column::make('actions')->className('min-desktop text-right')->orderable(false)->searchable(false),
251+
];
252+
}
253+
```
254+
**NOTE: In order to omit the `email_verified_at` class from my Index columns all I had to do is comment it out (or better yet, just remove it from the list of columns!)**
255+
256+
The datatables are also responsive by default (Checkout https://datatables.net/extensions/responsive/ for more details). For this purpose, you can use one of the following jig-provided responsive breakpoints to automatically collapse the column below a given screen size. For info on how to use the class logic, checkout the [Class Logic Documentation](https://datatables.net/extensions/responsive/classes). Most of the time I only use `min-`, e.g `min-desktop-l`
257+
```ts
258+
breakpoints: [
259+
{ name: "tv", width: Infinity },
260+
{ name: "desktop-l", width: 1536 },
261+
{ name: "desktop", width: 1280 },
262+
{ name: "tablet-l", width: 1024 },
263+
{ name: "tablet-p", width: 768 },
264+
{ name: "mobile-l", width: 480 },
265+
{ name: "mobile-p", width: 320 },
266+
],
267+
}
268+
```
269+
Checkout the first snippet on how I have used the responsive classes!
270+
271+
228272
### Testing
229273

230274
``` bash

0 commit comments

Comments
 (0)