Comments (6)
I will try to make it work. Thank you for suggestion with $sortable
array.
Isn't it possible to use https://github.com/Kyslik/column-sortable#columnsortable-overloading-advanced ?
from column-sortable.
Yes, overloading for the total field works for my example above.
public function totalSortable($query, $direction)
{
return $query->orderBy('total', $direction);
}
I think that this is probably the best solution rather than allowing the configuration of fields to be set.
public $sortable = [
'total' => 'total',
'balance' => 'balance',
'anotherAliasedField' => 'anotherAliasedField',
'created_at',
];
Doesn't look great as it's not obvious why you would be repeating the field name and i can't think of another use case for allowing that.
This is related to #24 as it would solve that guy's problem.
from column-sortable.
I think something like introducing new variable would be nice, maybe:
$sortableAliases = []
Or something similar, I will think about it and make it work.
WIP, aliases expected in new minor version
from column-sortable.
@veganista Hey, I was thinking about fixing this issue.
Anyway, #24 won't be fixed by this because OP uses accessor (manipulation with data after it is fetched) so there is no (virtual) column that package can sort by; in example below I show query with full_name and package could sort by it...
SELECT neededfield, CONCAT(firstname, ' ', lastname) as full_name ...
For that purpose there is that overloading functionality (which I use a lot in my projects), custom joins, custom selects etc.
I will try fix this soon.
from column-sortable.
@veganista try on dev-master
, see README.md and please report back if everything OK.
from column-sortable.
Sorry for the delay in getting back on this, took me a while to get back on the project.
Works as expected and much more concise than overloading.
Thanks
from column-sortable.
Related Issues (20)
- Sortable Union HOT 1
- Configurable parameters
- Laravel 9 support HOT 2
- Problem with Relation, Maximum execution time of 60 seconds exceeded HOT 1
- Sorting json column don't work HOT 1
- How to use sortable inside of a query done inside controller. HOT 1
- Calculation sortability
- use multiple sortable item in one view/component
- @sortablelink Appending Hash Fragments
- Incompatibility with Laravel 9 Scout
- I want to default some sorting to desc HOT 1
- How to use sortable in case of belongsToMany binding?
- Kyslik\ColumnSortable
- 3nd parameter does not working
- "warning" if $element in strlen($element) have null value
- Method Illuminate\Http\Request::allFilled does not exist. HOT 3
- sort relation column HOT 3
- How to go back to default sorting?
- Making the entire TH sortable HOT 1
- Use bootstrap icons instead of fontawesome
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 column-sortable.