Skip to main content link. Accesskey S
  • Translate Page ▼
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • Lotus Notes and Domino Application Development wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.0
  • 6.5
  • 8.0
  • 8.5
  • 8.5.1
  • 8.5.2
  • 8.5.3
  • action bar
  • Agents
  • Ajax
  • app dev
  • beginner
  • C&S
  • calendaring and scheduling
  • client
  • composite applications
  • Controls
  • converters
  • css
  • Custom controls
  • Data Binding
  • db2
  • design elements
  • dialog boxes
  • Documents
  • Dojo
  • Domino
  • Domino Designer
  • Domino Designer 8.5
  • DXL
  • Eclipse
  • error handling
  • errors
  • extensions
  • FAQ
  • Forms
  • formulas
  • getting started
  • globalization
  • Help
  • html
  • Installation
  • interface
  • internationalization
  • Java
  • JavaScript
  • JSF
  • localization
  • Lotus Domino Designer
  • LotusScript
  • LotusSphere
  • LotusTechInfo
  • menu bar
  • Mobile
  • new user
  • Notes
  • Notes 8
  • notes.ini
  • NSD
  • OpenNTF
  • partial update
  • performance
  • Pickers
  • Portal
  • presentations
  • programming
  • Redbooks
  • Requested Articles
  • roadmap
  • rooms and resources
  • samples
  • Scripting
  • security
  • tabs
  • templates
  • themes
  • Tips
  • toolbar
  • troubleshooting
  • tutorials
  • validation
  • variables
  • video
  • VideoFest
  • View
  • view control
  • ViewPanel
  • Views
  • web
  • Web apps
  • Web services
  • webdev
  • x-pages
  • XML
  • Xpage
  • XPages
  • XPages Extensibility API
  • XPages Extension Library
  • xsp-config
  • データソース
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Designing CSS and Themes > Coloring Specific View Rows Using a Dynamic Table and CSS in XPages
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Coloring Specific View Rows Using a Dynamic Table and CSS in XPages 

expanded Abstract
collapsed Abstract
No abstract provided.

I had a student ask recently about the ability to set the background color of a table row based upon a value in the data.  This is something that was pretty commonly done in traditional Domino Web Development.  In investigating how to do this I couldn't find a way to implement this using the standard View control, so I developed the following technique.

I use a dynamic html table (I showed how to implement this in my post http://xpagesblog.com/xpages-blog/2009/9/23/creating-a-dynamic-html-table-on-an-xpage.html" title="here">here ) but this technique can be used with a Data Table as well.

Create a CSS Style sheet that will map the colors to be used to the data values from the Domino View data. In the View I'm using as a data source there is a column that contains a Status value with one of the following values in it

  • New
  • Existing
  • Terminated
  • Pending

I have the following CSS in a stylesheet resource called rowclasses.css that I will be using in this demo.

.New {
background-color: red;
}
.Existing {
background-color: blue;
}
.Terminated {
background-color: fuchsia;
}

The class definitions in the CSS stylesheet are the same as the values from the status column.

Add the style sheet as a resource for the XPage.

 

 Before the Stylesheet is applied the XPage rendered in the browser looks like the following

 


We want the individual table rows background color to be set using the colors from the CSS style sheet based upon the value from the Status column in the View data.

To review, the dynamic table uses a repeat control that has a variable called "customers" for each row of data that will be displayed.  The value in the status column can be read from that variable using the Expression Language syntax customers.Status.

To set the value of the table rows background color, select the table row.  On the Style tab of the Properties tab click the computed diamond icon next to the Class field and choose "Compute value...".


 

In the Script Editor dialog box that opens up change the language to Expression Language and type in the expression customers.Status.  Click the OK button to save the expression to the class field.


Save the XPage and preview it in the browser.  Now each rows background color will be set to the value in the CSS stylesheet based upon the value from the status column.


The status column does not have to be displayed, but it does have to be available in the data.

The style does not have to be applied to the entire row, it could be applied to one or many table cells as well.

The application with complete source code can be downloaded from my website http://www.nnsu.com" title="here">here 


expanded Article information
collapsed Article information
Category:
Designing CSS and Themes, Designing the User Experience, Designing XPage Applications,
Tags:
XPages, CSS, Themes

This Version: Version 2 February 23, 2010 12:24:55 PM by Paul Calhoun  
   
expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (2)
collapsed Versions (2)
expanded Version Comparison
collapsed Version Comparison
     
Version Date Changed by               Summary of changes
This version (2) Feb 23, 2010 12:24:55 PM Paul Calhoun  
1 Feb 23, 2010 12:22:11 PM Paul Calhoun  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Tip: When linking to articles use the original title, not the edited title. The alias for the link can be the edited title.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • Lotus Technical Information and Education Team Blog
  • Lotus Tech Info on Twitter
  • Lotus Tech Info on Facebook
  • Lotus product forums
  • Lotus Tech Info blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use
Return to English
Arabic
Chinese Simplified
Chinese Traditional
French
German
Italian
Japanese
Korean
Portuguese
Russian
Spanish