PDA

View Full Version : Right justifying numeric columns in grid?



robert
20 Oct 2006, 7:11 PM
What is the best way to right justify numeric columns in the grid? Using a custom renderer to left pad with spaces does not work as multiple spaces are ignored in the browser. Left padding with 0 or _ works but is ugly :-)

robert
20 Oct 2006, 9:08 PM
Answering my own question...

Trying to use a renderer was too complex, the simplest way is to look at the grid.css file where you will find :


/*
The grid first check if a column style is defined as:
#your-grid .ygrid-col-0
if it doesn't find it, it uses one of the generic empty rules below.
If you have more than one grid on your page - you MUST define you columns
like above - #container-id .ygrid-col-0 and they must each be a separate rule
*/
.ygrid-col-0{
}
....


so just redefine the css rule for the numeric columns in your grid to use text-align:right, e.g.

.ygrid-col-15{
text-align:right;
}

and all the numbers in column 15 will be right justified.

jack.slocum
21 Oct 2006, 4:43 AM
If you define it directly in grid.css or in your default css for your site, you would probably want to prefix it with your gridid.


#mygrid .ygrid-col-15{
text-align:right;
}

This way only that grid's 15th column get aligned right. If you use the generic rules, it will apply to every grid.

Thanks for sharing as you learn Robert. I'm sure you will be saving people time by posting these great tidbits so they don't have to try to figure it out all over again.

eertl
7 Jan 2009, 3:35 PM
I tried this but with no luck :( Has anything changed?:-/

alacol
14 Oct 2010, 10:31 AM
I tried this but with no luck :( Has anything changed?:-/
Inspect the column object using Firefox to find out it's name

In my case for example it's:


#stats_grid .x-grid3-col-1{
text-align:right;
}