You need to sign in to do that
Don't have an account?

alternate color for table row.
Hi i have created a one visual force page whic is rendering as PDF.
In this one table is rendering dynamicaly(not a apextable). I want to show table row in alterante color. i found some line of code which used JQuery, this works fine when i render as html but now when , i render it as 'PDF'
$(document).ready( function(){
$("#myTable tbody tr:visible:even",this).css('background-color','#fffffe');
$("#myTable tbody tr:visible:odd",this).css('background-color','#e0dfde');
}
)
Please tell solution ASAP.
You won't be able to do this via jquery, or any kind of javascript, as there isn't a javascript engine associated with PDF renderers. You'd need to do this via CSS - there's a soluton at:
http://stackoverflow.com/questions/3084261/alternate-table-row-color-by-css
but note that IE and some firefox versions don't support this.
Hello.
I know this thread is a couple of months old, but I had a similar requirement and found a solution that worked for me.
In my case, my Visualforce page is controlled by a custom controller and is rendering as a PDF. In my controller, I have a wrapper class that, in addition to the object that I'm returning, also includes an "index" integer that's incremented for each record returned. A sample wrapper class is defined below:
Then, in the Visualforce page, in the <apex:repeat> loop, I'm performing a simple MOD function to determine if the index is odd or even, and applying an "altRow" class on even rows:
Hope that helps.
-Greg
just to add: there is an alternative solution using <apex:variable> to alternate row's classes coined by Mitesh Sura here: https://developer.salesforce.com/forums/ForumsMain?id=906F00000009FKiIAM
Regards,
Vladimir