Limit characters per column #241
-
Hi, Is there any way to limit the number of characters ( display text ) per column? I am looking for something similar to Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello there, You can use a closure to create an excerpt for your For example, imagine you have a database table
You can do something like: <?php
use Illuminate\Support\Str;
//...
public function addColumns(): ?PowerGridEloquent
{
return PowerGrid::eloquent()
->addColumn('id')
->addColumn('title')
->addColumn('author')
->addColumn('text_preview', function (Poem $poem) {
return Str::words($poem->text, 10); //Gets first 10 words
});
} The outcome will be:
Read more here: https://livewire-powergrid.com/#/table/add-columns?id=closure-examples ⭐ Did it solve your problem? Consider Starring this Repository! |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your quick response. Best Regards. |
Beta Was this translation helpful? Give feedback.
Hello there,
You can use a closure to create an excerpt for your
text
column.For example, imagine you have a database table
poems
with the following data: