Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- alternate color for table row.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
alternate color for table row.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-14-2012 06:32 PM
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','#ff
$("#myTable tbody tr:visible:odd",this).css('background-color','#e0d
}
)
Please tell solution ASAP.
Hit the Kudos button (star) if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.
Re: alternate color for table row.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-15-2012 12:31 AM
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/alterna
but note that IE and some firefox versions don't support this.
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
Re: alternate color for table row.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-30-2013 08:54 AM
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:
private class objWrapper {
public Custom_Object__c deal {get;set;}
public Integer index { get;set;}
public objWrapper(Custom_Object__c d, Integer i){
obj = d;
index = i;
}
}
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:
<table>
<apex:repeat value="{!getterClassHere}" var="d">
<tr class="{!IF(MOD(d.index,2)==1,'','altRow')}">
<td><apex:outputText value="{!d.obj.Name}"/></td>
</tr>
</apex:repeat>
</table>
Hope that helps.
-Greg

