alperenersoy/filament-export

[Admin] Column data truncated when ->limit() is used

carestad opened this issue · 0 comments

In admin panels it can consume a lot of width if full URLs etc. are shown, so I have truncated them with ->limit(), and when exporting via header actions, the truncated values are being brought into the XLSX sheet. Is there a way to bypass this for the exports?

Example code:

<?php

namespace App\Filament\Resources;

use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
use App\Filament\Resources\ExampleResource\Pages;
use App\Filament\Resources\ExampleResource\RelationManagers;
use App\Models\Example;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;

class ExampleResource extends Resource
{
    protected static ?string $model = Example::class;
    protected static ?string $navigationIcon = 'heroicon-o-collection';
    protected static ?string $navigationGroup = 'Example';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')->required(),
                Forms\Components\Textarea::make('description'),
                Forms\Components\Select::make('owner_id')->relationship('owner', 'name')->label('Owner')->required(),
                Forms\Components\Select::make('category_id')->relationship('category', 'name')->label('Category')->required(),
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                Tables\Columns\TextColumn::make('id')->label('ID')->sortable(),
                Tables\Columns\TextColumn::make('name')->sortable()->limit(30),
                Tables\Columns\TextColumn::make('description')->sortable()->limit(30),
                Tables\Columns\TextColumn::make('category.name')->sortable(),
                Tables\Columns\TextColumn::make('owner.email')->sortable(),
                Tables\Columns\TextColumn::make('created_at')->dateTime()->sortable(),
                Tables\Columns\TextColumn::make('updated_at')->dateTime()->sortable(),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\ViewAction::make(),
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\DeleteBulkAction::make(),
                FilamentExportBulkAction::make('export'),
            ])
            ->headerActions([
                FilamentExportHeaderAction::make('export'),
            ])
            ->defaultSort('id', 'desc');
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListExample::route('/'),
            'create' => Pages\CreateExample::route('/create'),
            'view' => Pages\ViewExample::route('/{record}'),
            'edit' => Pages\EditExample::route('/{record}/edit'),
        ];
    }
}