KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

CSS formating columns in a table, color, text aligne etc #2661

Open Francois DISSAIT opened this topic on on May 7, 2022 - 8 comments

Francois DISSAIT commented on May 7, 2022

Hello, I have a problem I can't solve. I a table, I want one of the columns in red color and right aligned. I cannot enter the two statements : color and text_align in the "cssStyle", only one works : or text is green, or text is right justfied, but not the two ... green AND right justified . Here is my view file :

<?php
Table::create(array(
    "dataSource"=>$this->dataStore('stocks'),
	
	"sorting"=>array(
		"Article"=>"asc",
					),
	"columns"=>array(
        "Article"=>array(               
			 "label"=>"Article"
						),
		"Stock"=>array(				
            "label"=>"Stock",
			"cssStyle"=>"text-align:right"
							),
       	"Rentres"=>array(
            "label"=>"Rentres",	

"type"=>"number", "cssStyle"=>"color:green", "cssStyle"=>"text-align:right"

							),
		"Poids"=>array(
			"label"=>"Poids",				
			"cssStyle"=>"text-align:right"
					),
					),
	  "cssClass"=>array(
        "table"=>"table-bordered table-striped table-hover"
						)
	
));
?>
KoolReport commented on May 9, 2022

You try:

"cssStyle"=>"text-align:right;color:green"

Let us know if it works.

Francois DISSAIT commented on May 13, 2022

OK, thanks a lot, it works FD

eMaX commented on Apr 30, 2023

but how can you change the background color of a cell?

Francois DISSAIT commented on Apr 30, 2023

Try using background-color : blue in the css style command chain

Francois DISSAIT commented on Apr 30, 2023

"cssstyle"=>"text-align : right; backgroung-color : red ; color : green" gives a green text on a red background. ; is the separator between instructions.

eMaX commented on May 1, 2023

Thank you. But how do I change the cell background, not the text background? I don’t want the text appear like it was highlighted, I want to change the entire table cell’s background.

Francois DISSAIT commented on May 1, 2023

Maybe you can try this : You can customize the css class given to element in table such as table, tr, th. For example:

<style>
    .cssHeader
    {
        background-color:#e9ffe8;
    }
    .cssItem
    {
        background-color:#fdffe8;
    }
</style>
<?php
Table::create(array(
    "dataSource"=>$this->dataStore('data'),
    "cssClass"=>array(
        "th"=>"cssHeader",
        "tr"=>"cssItem"
    )
));
?>
eMaX commented on May 1, 2023

Thanks François. I want to change that depending on the value that is displayed in a cell.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

None