Comments (3)
This would be awesome.
At a minimum CSV would be good (ie JsonCSV).
I do see a possible issue when exporting large amount of data.
Inertia seems to imposed a 640k limit (at least on firefox) as I keep getting NS_ERROR_ILLEGAL_VALUE when trying to access large datasets.
I expect, it may require a second controller, via an api style call (ie not rendered by Inertia) to pass all the data (axios etc).
Would be nice to pass the current filters and column status props so you can match what is being displayed.
Cheers.
from inertiajs-tables-laravel-query-builder.
I made a controller for this, using FastExcel for export.
https://gist.github.com/mUcHG0Di/9d133aec56cfe98d3296bca0c64aad74
Instructions are commented in the gist, but in a few words:
- Create an extension of InteractsWithQueryBuilder.vue, to remove the following condition in method getColumnsForQuery:
if (enabledColumns.length === Object.keys(columns || {}).length) {
return [];
}
-
Import your new InteractsWithQueryBuilder file in your view, instead of the original one:
import InteractsWithQueryBuilder from '@/InteractsWithQueryBuilder';
-
Create a button or something, that executes the following:
const query = this.queryBuilderString; // The query
const url = route('excel.export'); // Your export route
const model = 'App\Models\User'; // The model to export
window.location.href = `${url}?${query}&model=${model}`
- Add the route:
Route::get('excel/export', \App\Http\Controllers\ExcelController::class)->name('excel.export');
Obs.: Relation columns should be with dot notation, and you need to create the Sort class in app/Sorts/{MainModel}/{RelationModel} with Sort suffix, ie: app/Sorts/Product/OwnerSort.php (to support sorting)
Example:
return Inertia::render('Users/Index', [
'users' => $users,
])->table(function (InertiaTable $table) {
$table->addColumns([
'email' => 'Email address',
'category.name' => 'Category',
'latestHistory.status.name' => 'Status',
]);
});
And it should work with no modifications.. In most cases :')
from inertiajs-tables-laravel-query-builder.
PDF/XLS exports are out of scope for this package, but I suggest looking at Laravel Excel. Maybe you could use the Collection Export feature.
from inertiajs-tables-laravel-query-builder.
Related Issues (20)
- Input search range ( example for price min & max) HOT 8
- Reset button not working when global search is in slots HOT 3
- Is selectFilter using wildcards? HOT 2
- Chrome global search doesn't seem to be holding its focus state HOT 1
- I there any way to selectFilter sort by if the value is numerical HOT 5
- Laravel Mix build requires imports to have .js extensions HOT 2
- Support for Bootstrap
- style HOT 2
- API Resource
- v2.1.0 error popper.js with Vite 3.1.3 HOT 1
- Request for Tailwind CSS Prefix Option
- [FEATURE]: Support for default scaffolding like jet stream should be provided. HOT 1
- -1 as perPage parameter creates invalid SQL queries
- Column option to sort null values last HOT 1
- Compatibility with Inertia.js v1 HOT 4
- Proper way to style the table? HOT 1
- Pagination: changing page submits two requests HOT 2
- ⚠️ Don't start using this package for new projects HOT 9
- Reset button not working when used in slots HOT 3
- How to call a function when loading or reloading the table ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inertiajs-tables-laravel-query-builder.