MedicOneSystems / MedicOneSystems/livewire-datatables

Feature Request: Method callbackClasses()

Open
#123 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.2k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

Hello,

I think it would be good to create a method that allows making a callback to be able to add classes to the parent of the "td".

It would also be good if you can do the same for attributes in case you want to add some "data-xxx" or some other.

In my case I try to put a bg-red when the email is not verified, but in this case it is not possible because it would apply only to the content.

 Column::callback(['id', 'email_verified_at'], function ($id, $email_verified_at) {
      if($email_verified_at == Null) return "<span class='bg-red-500 text-white'>#$id</span>";

      return "<span class='bg-green-500 text-white'>#$id</span>";
      
  })
  ->label('ID'),

image

<div class="px-6 py-2 whitespace-no-wrap text-sm leading-5 text-gray-900 table-cell  text-left ">
      <span class="bg-red-500 text-white"># 40</span>
  </div>

Expected:

image

<div class="px-6 py-2 whitespace-no-wrap text-sm leading-5 text-gray-900 table-cell  text-left  bg-red-500 text-white">
      # 40
  </div>

I will try to do it later but in case someone wants to collaborate with a PR I would be grateful.

Thanks ! :D

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Column::callback entry point shown in the example and trace how its result is rendered into the table cell. The work is complete when a callback can add classes and custom attributes to the parent td, matching the requested red-cell HTML behavior; no test file is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, tailwind
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.