DataGrids
Views
DataGrid Views allow users to create named collections of filter sets, sorts, and column display settings. These collections can be saved and reapplied at a later date, providing a convenient way to quickly restore specific data grid configurations.
How Views Work
Each DataGrid automatically has view-related routes registered when using Route::dataGrid(). Views are stored in the database and are associated with a specific DataGrid via its grid key.
A view stores the following data:
- Filter Sets - The active filter sets and their filters
- Sorts - The active sort configuration
- Columns - Column display settings (field name and visibility)
API Endpoints
When a DataGrid is registered, the following view-related routes are available:
| Method | Path | Description |
|---|---|---|
| GET | {prefix}/{grid}/views | List all saved views |
| POST | {prefix}/{grid}/views | Store a new view |
| DELETE | {prefix}/{grid}/views/{view} | Delete an existing view |
Storing a View
To store a view, send a POST request with the following payload:
json
{
"name": "My Custom View",
"filter_sets": [
{
"filter_set_operator": "and",
"filters": [
{
"alias": "Name",
"filter_operator": "stringContains",
"value": "Andrew"
}
]
}
],
"sorts": [
{
"alias": "Name",
"sort_operator": "asc"
}
],
"columns": [
{
"field": "Name",
"is_hidden": false
},
{
"field": "Email",
"is_hidden": true
}
]
}