-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detecting sort in the column header #10
Comments
I've played around with extracting table headers to a Blade component. My first thought was to use a Livewire component, and to extend We just really needed a Blade component with a slot, to hide some of the ugly if statements shown in my initial comment. This is what I have come up with at this time:
ThoughtsNeed to provide prepared Previously we could just pass Sort button If the column is sortable we provide a button that has emits the sort even when clicked. I think this is more semantically correct than only clicking the . However I'm thinking we now need to provide style options for the button. Why don't we extract the entire header into a component, and loop over $fields? While this would be visually preferable, my reasoning against this is to provide the user the ability to edit the $slot (where column name is currently entered), if need be. This way it can be wrapped in a or what have you. Or even to insert cells in between others if necessary. |
Update on the header view components.
I tried to simplify it as much as possible by:
Any thoughts? Is this a good direction / addition to this package? |
Hey! I like this! Abstracting it out is definitely a good call... although I feel it can go further, even if I am not sure how that works just yet! i.e. @component('livewire-tables::th-cell', ['colNum' => 2, 'field' => $fields[2], 'css' => $css, 'sortField' => $sortField, 'sortDir' => $sortDir])
City
@endcomponent To something like... @component('livewire-tables::th-cell', $fields)
City
@endcomponent or... @livewire('livewire-tables::th-cell', $field) Or even better could the entire header row be livewire generated? @livewire('th-row', $fields) Doing as much of the logic as possible inside a php class would be nice too, almost like a view composer model (https://stitcher.io/blog/laravel-view-models). I have been playing around with changing the I believe there may be a bug within livewire that is preventing livewire logic from working insde a |
Hey @booni3 , I went down the same route and tried to make a Livewire component that handled the table header row / cells. The issue I ran into was that the sort configuration is set in the generated PHP component i.e. I've also been having conversation on the new Livewire forum on the direction of this package. See this discussion thread: https://forum.laravel-livewire.com/t/on-building-the-ideal-livewire-tables-package/40 iAmKevinMcKee on that forum has a great addition to Livewire with customizable stubs. This kind of blew my mind. Maybe the Livewire Tables package should leverage this, ship with one or many table "stubs" that can also be generated by the end user to have completely configurable pre-made table views. Maybe we can even break up the stubs, i.e. include a default table header stub. I really need to wrap my head around how this would work in addition to the scaffolding that takes place. This core idea here has really halted me on this project until I can figure out the best way to move forward, as I think it could affect how the entirety of the package works. |
Currently the
<th>
header cells do not detect when / if they are sorted.I think I'll end up having to extract them into a component where we can pass different states, such as a base class (passing in from config / table $css array), and ascending class, and a descending class.
$fields
could be modified to support aascending_class
anddescending_class
strings.It's going to get pretty dirty..
The text was updated successfully, but these errors were encountered: