List view: How to make row text smaller, and have hover over row showing values in 'title' style popup #816
-
Any help much appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
HI @gvanto For Tooltip: To make values shorter: CRUD::column('content')->wrapper([
'element' => 'span',
'class' => 'd-inline-block text-truncate',
'style' => "max-width: 100px;",
'data-bs-toggle' => "tooltip",
'data-bs-placement'=> "top",
]); I'm sure you want to do it to many columns. To avoid placing the code in every column, we can Add new methods to the CrudColumn class and use it for any column. //app/Providers/AppServiceProvider.php
public function register()
{
/*...*/
if (! CrudColumn::hasMacro('customThing')) {
CrudColumn::macro('customThing', function ($firstParamExample = [], $secondParamExample = null) {
/** @var CrudColumn $this */
$this->wrapper([
'element' => 'span',
'class' => 'd-inline-block text-truncate',
'style' => "max-width: 100px;",
'data-bs-toggle' => "tooltip",
'data-bs-placement'=> "top",
]);
return $this;
});
}
But there will be a problem, you want to put column value as a tooltip title, which I don't know if we can pass from CRUD. Final thought:If I was doing that. I would create a custom column, where I'm free to get the value and set HTML/ CSS as I want. You can quickly create a column using the following command: Note: This will also require steps to make custom JavaScript work with Backpack's List Operation. |
Beta Was this translation helpful? Give feedback.
-
Brilliant thanks @karandatwani92 for in-depth answer ... handy stuff to know about the JS, very powerful, love it! I actually managed to do this with custom column (although I noticed that my final column specified in setupListOperation (updated_at) is not being added to the columns (maybe due to space issue?). What I would like to do now is override the action columns - just use the icons (dont need the 'Delete' and 'Preview' words next to them) ... hopefully this is possible... |
Beta Was this translation helpful? Give feedback.
-
Works like a dream, thanks @karandatwani92 ! To get the 'tooltip' working (not a real tooltip, just title) I am using this in my custom column which works OK:
|
Beta Was this translation helpful? Give feedback.
HI @gvanto
For Tooltip:
Here is an article on adding a tooltip on columns/list operation as it's example:
https://backpackforlaravel.com/articles/tutorials/how-to-make-custom-javascript-work-with-backpack-s-list-operation
To make values shorter:
We can add text-truncate class using wrapper:
I'm sure you want to do it to many columns. To avoid placing the code in every column, we can Add new methods to the CrudColumn class and use it for any column.