-
hello colleagues how can I concatenate columns in this version I have something like this
and throws this error every time, what am I doing wrong?
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
It'll look for the name of your column as the db field unless you specify a second parameter in the column make. Alternatively, use the label approach from the documentation Column::make('My one off column') ->label( fn($row, Column $column) => $this->getSomeOtherValue($row, $column) ), |
Beta Was this translation helpful? Give feedback.
-
hi friend I'm using the label documentation and it doesn't recognize the methods, I think my library has a problem
and return my composer.json:
thank you for your help |
Beta Was this translation helpful? Give feedback.
-
When you're using the following example: If the function is in your model (for example), then you'd want to use $row->getSomeOtherValue() instead, passing the relevant parameters. You can change getSomeOtherValue to whatever you choose to name your function. As an example, in my TaskList table I have the following: Column::make('Open Tasks') This column calls a function that is named openTasks. This function is stored within my TaskList model, which returns the number of open tasks that a particular tasklist has. If you're still stuck, then please drop both the DataTable component, and the related Model somewhere that I can see them :) |
Beta Was this translation helpful? Give feedback.
-
You should be able to use this to exclude from the database column selection. That said I discovered an issue with this if you can try with this small change: #911 public function getSelectableColumns(): Collection
{
return $this->getColumns()
->reject(fn (Column $column) => $column->isLabel())
->filter(fn (Column $column) => $column->isSelectable())
->values();
} |
Beta Was this translation helpful? Give feedback.
When you're using the following example:
Column::make('My one off column')
->label(
fn($row, Column $column) => $this->getSomeOtherValue($row, $column)
),
If you're using $this->getSomeOtherValue, then that needs to be a function that will return the data that you want to display. It can either be a function on the DataTable component (or a parent component).
If the function is in your model (for example), then you'd want to use $row->getSomeOtherValue() instead, passing the relevant parameters.
You can change getSomeOtherValue to whatever you choose to name your function.
As an example, in my TaskList table I have the following:
Column::make('Open Tasks')
->label(fn ($row) => $row->openT…