Page 1 of 1

Right Align Cell Contents

PostPosted: Mon May 16, 2011 3:32 pm
by orillia319
I recently purchased the paid version and am in learning mode.

I've tried to use a callback function to format a currency field on the table/list page (I added 'annual_salary' to the employees table in one of the examples). The callback function is as follows:

Code: Select all
function formatCurrencyValue($col,$value,$row)
{
   return '<span style="text-align:right">' . '$' . number_format($value, 2) . '</span>';
}


This style setting seems to be ignored in both Firefox and IE (other non-alignment styling works OK), so perhaps trying to set alignment inside a <td> does not work. Is there another workaround, or perhaps a way to gain access to the <td> tag instead before it's rendered?

Thanks.

Re: Right Align Cell Contents

PostPosted: Mon May 16, 2011 3:43 pm
by orillia319
I believe I've solved my own problem.

I had tried defining a class for the style tag, as well as quite a few other options. Just after posting my message, I replaced the span tag with a div and I now have the desired text alignment.

Here's the slightly altered code:

Code: Select all
function formatCurrencyValue($col,$value,$row)
{
   return '<div style="text-align:right">' . '$' . number_format($value, 2) . '</div>';
}

The above works with both Firefox 4 and IE 8.

Re: Right Align Cell Contents

PostPosted: Mon Aug 22, 2011 6:33 pm
by vinny1057
very interesting, thanks.