Broken query and sorting not working when using custom column type #1229
-
Hi, just found this project recently, fantastic job. To the point: What I wanted to achieve is display name in table column with the link pointing to the details page. My first thought was to use public function columns(): array
{
return [
LinkColumn::make('Name', 'name')
->title(fn($row) => $row->name)
->location(fn($row) => route('some.route.edit', [
'id' => $row->id
]))
->sortable(),
];
} Problem is that constructor uses public function __construct(string $title, string $from = null)
{
parent::__construct($title, $from);
$this->label(fn () => null);
} What this method does is resetting public function label(callable $callback): self
{
$this->from = null;
$this->field = null;
$this->labelCallback = $callback;
return $this;
} I guess this is intended, I've done some searching (#946, #961) and found solutions like using There is also other problem - query not having field (reset by public function builder(): Builder
{
return SomeClass::query()->select();
} Otherwise LinkColumn::make('Name', 'name')
->title(fn($row) => $row->name) Is it a bug or maybe I do something wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use setAdditionalSelects() in your configure() method to add extra fields to the query. Sortable labels fix is in an upcoming (likely next) release. |
Beta Was this translation helpful? Give feedback.
You can use setAdditionalSelects() in your configure() method to add extra fields to the query.
Sortable labels fix is in an upcoming (likely next) release.