Skip to content

feat(datatables): add Column::visible() for conditional column visibility#113

Merged
sebastienheyd merged 1 commit intomasterfrom
feat/datatable-conditional-columns
Feb 14, 2026
Merged

feat(datatables): add Column::visible() for conditional column visibility#113
sebastienheyd merged 1 commit intomasterfrom
feat/datatable-conditional-columns

Conversation

@sebastienheyd
Copy link
Owner

@sebastienheyd sebastienheyd commented Feb 14, 2026

Summary

  • Add Column::visible(bool) method to dynamically toggle column visibility based on request parameters (e.g., ->visible(request()->post('showMine', false)))
  • Simplify Column::hidden() to delegate to visible(false)
  • Guard against columns without data in Datatable::make() to prevent errors with special columns

Closes #92

Usage

Instead of conditionally adding/removing columns (which causes "column not found" errors), always define all columns and use visible():

public function columns(): array
{
    return [
        Column::add('ID')->data('id'),
        Column::add('Name')->data('name')->visible(request()->post('showMine', false)),
    ];
}

Test plan

  • Column::visible(true) does not add visible to attributes
  • Column::visible(false) sets visible: false
  • Column::hidden() still works as before
  • Column::hidden()->visible(true) removes the hidden state
  • All 232 tests pass

…lity

Allow users to dynamically show/hide columns based on request parameters
without triggering "column not found" errors. Columns should always be
defined in columns() and use visible() to toggle visibility conditionally.

Also guard against columns without data in Datatable::make() to prevent
errors with special columns.

Closes #92

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sebastienheyd sebastienheyd merged commit c357b97 into master Feb 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Datatables] Hide columns based on ajax propery

1 participant