Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for row attributes and callable cell attributes. #3

wants to merge 1 commit into from


None yet
2 participants
Copy link

commented Jun 15, 2019

Hi there, thanks for this library! 馃檶

I've been using it for a while in a project I'm working on and have found it really useful, but came up with a requirement to customise the generated <tr> elements (e.g. adding data- and class attributes).

First I tried creating a new class to extend it, but had problems due to the variables being declared private; so I forked it instead - you can see the changes here.

I updated test1.php example with some use cases - setting the 'class' and adding a data-id attribute based on row properties.

The way I achieved this - updating Properties class to support callables - also means that the attr() and css() calls for cells can also have values returned from callables.

Please feel free to merge if you find it useful!


This comment has been minimized.

Copy link

commented Jun 18, 2019

Hi Craig,
Thanks for the suggestions. Makes perfect sense.
Regarding the implementation I think to add attributes and css to different tags I would rather have something like:

->attr('table', 'width', '100%')
->attr('tr', 'data-text', 'bla bla bla bla bla')
->css('tr', 'background-color', 'red')
		->value(function ($row) {
			return rand(1,10)%2 ? '<b>'.$row['name'].'</b>' : $row['name'];
		->attr('td', 'data-text', 'bla bla bla')
		->css('th', 'color', 'green')
		->css('td', 'width', '50%')
		->css('td', 'background-color', '#ccc', true)


I used your suggestions and added a development branch with the ideia. I have not implemented the callables feature but take a look and tell me what you think.

@craigrodway craigrodway referenced this pull request Jun 19, 2019


Updated callable values #4


This comment has been minimized.

Copy link
Contributor Author

commented Jun 19, 2019

Hi, thanks for your reply!

I agree, I prefer that syntax and makes more sense that way. I think I was being cautious not to break compatibility too much, but this way is good. I've checked it out and like it how it works.

I've made some adjustments to support callable values which you can see in PR #4 .

@jupitern jupitern closed this Jun 19, 2019


This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.