Buy Now
Sign in

How to add html class to a table ROW, or programmatically to a CELL?

healyhatman , April 27 at 03:03
Answered
healyhatman
As in the title : is there a way to add a class to a particular ROW in a table, or to an individual cell? So I can for example apply a negative/positive class or a colour to either?
See https://semantic-ui.com/collections/table.html#positive--negative for an example of what I'm after
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
healyhatman
Bump, would very much like this please.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Hi
Sorry for delay - just spotted your query.
Is this CSS what you need?

​tbody tr.even td {​
​ background: none repeat scroll 0 0 whitesmoke !important;​
​}
That produces this
4chrono.jpg
Attachments
4chrono.jpg
4chrono.jpg
(45.37 KiB)
80 Downloads/Views
healyhatman
No. I need to be able to add the CLASS to the row or cell to be able to target it with CSS and there's no way (currently that I can see) to add it in CCv6
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Hi - just realised that you are down the road from me - up in Port.
I have used the class box in the Table view to apply classes to th and td tags. Any help?
4chrono.jpg
Attachments
4chrono.jpg
4chrono.jpg
(180.59 KiB)
56 Downloads/Views
4chrono.jpg
4chrono.jpg
(190.03 KiB)
52 Downloads/Views
4chrono.jpg
4chrono.jpg
(190.03 KiB)
66 Downloads/Views
healyhatman
no. Row and cell not column.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
That example above - that includes css configuration for the row (the shading) and cell (the badge) does it not?
healyhatman
and how are you going to add the class to the row or cell? As in
<td class = "myclass">
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Via that column classes box.
4chrono2.jpg
That generates
4chrono3.jpg
And I added the div colours as an HTML function on the columns view.
Attachments
4chrono.jpg
4chrono.jpg
(17.41 KiB)
52 Downloads/Views
4chrono2.jpg
4chrono2.jpg
(32.33 KiB)
50 Downloads/Views
4chrono2.jpg
4chrono2.jpg
(32.33 KiB)
64 Downloads/Views
4chrono3.jpg
4chrono3.jpg
(38.31 KiB)
62 Downloads/Views
healyhatman
Okay so I need it programmatically. So for example, if classFee is 1.5 then add "classA" to the row. If classFee is 2 add "classB" to the cell.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Yes - pro grammatically. I used this approach
<div class='clsBadge' ​
​style='color:{var:masterYears.row.mdlMasterYears.badgeDisplayText} !important; ​
​border:solid medium {var:masterYears.row.mdlMasterYears.badgeDisplayText} !important;'>​
​{var:masterYears.row.mdlMasterYears.intYear}​
​</div>
rather than maintain a set of classes but that would no doubt work if you could anticipate all of the likely values,
healyhatman
Thanks for the input but again I need it added to the cell or individual row itself.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
OK
And there I am stuck since as far as I can see and from my usage that method does add css to a specific cell admittedly via the tag style attribute based on the cell content.
Nick
healyhatman
No you're adding a class to content INSIDE the cell.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
OK - I see that difference. I shall ponder further - it needs some sort of css:parent selector. I wonder if one can add a {fn:...} to the Column Classes box or the Columns Views box.
Nick
healyhatman
There is no css parent selector, and even if there was that's still not what I need. I want to utilise Semantic-UIs table behaviour for positive / negative cell entries.
I'll probably just have to see if I can modify the PHP files for CC and add the requisite options to the table builder.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
No - there is not for reasons explained elsewhere - but a pity.
I shall watch with interest.
healyhatman
OK I got it. I modified table_config to add a row option and table_output to display it. You can add text classes in there or function calls - but for some reason if you call a PHP function it has to echo your class string instead of returning the string.
USAGE: remove the '.txt' and upload the files to /server/path/public_html/yoursite/libraries/cegcore2/admin/extensions/chronofc/views/table
REMEMBER: These additions will be overwritten when you update chronoforms/connectivity.
Attachments
table_config.php.txt
(4.38 KiB)
40 Downloads/Views
table_output.php.txt
(3.98 KiB)
32 Downloads/Views
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
NickOg
Thanks for that.
Noted 'REMEMBER: These additions will be overwritten when you update chronoforms/connectivity.'
healyhatman
This just adds the class to the ROW though not individual cells. I can do that later but for my purposes the row was more important.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman