Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Web Experience Factory wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category Web Experience Factory 8 Documentation WebSphere Portlet Factory 7 Documentation WebSphere Portlet Factory 7.0.1 Documentation Custom Search Scope...
Search
Community Articles > Resources for Developers > Creating a Responsive Data Table
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

IBM contributorGarry Sager
Contribution Summary:
  • Articles authored: 14
  • Articles edited: 0
  • Comments Posted: 1

Recent articles by this author

Using the new responsive HTML template provided with the Feature Pack for Web Experience Factory 8

The new fp80responsivetemplate.html template allows details, create, and update pages to dynamically and responsively support a two column layout. The template has a layout that uses css floats to lay out the fields. Columns are automatically laid out with the first field in the first column and ...

Using the new Multichannel Responsive Data Layouts provided with the Feature Pack for Web Experience Factory 8

In this article we will talk about the new data layouts that we created for this feature pack. These layouts are designed to work with the new responsive theme for portal 8.0.0.1 and the new Web Experience Factory theme defined in this feature pack. Some of these layouts require the new portal ...

Connecting IBM Web Content Manager content to Web Experience Factory portlets

This sample illustrates how to integrate portlets that display content from IBM Web Content Manager which I will refer to as WCM and portlets that are developed using Web Experience Factory which I will refer to as WEF. It shows how a custom portlet can use public render parameters from the ...

Sharing an Eclipse shell with the Web Experience Factory Designer and Worklight Studio

These are the steps you need to follow to share an eclipse development environment with both Web Experience Factory 8.0 and Worklight Developer Edition 5.0. There are many different versions and configurations of eclipse and many do not contain all the plugins required for both Worklight and Web ...

Working with Themes

This article gives you an over view of how Web Experience Factory themes are used in projects and models with information about how to control the look and feel of your applications and portlets. This also includes multichannel techniques and tips for working on phones, tablets and desktop ...

Community articleCreating a Responsive Data Table

Added by IBM contributor Garry Sager | Edited by IBM contributor Garry Sager on March 22, 2012 | Version 7
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: builder, css, mobile, responsive UI
Prerequisites

You should have a basic familiarity with Web Experience Factory, HTML and styles. You should also know how to create and run models. The Tutorials And Samples/Building Models feature also should be added to the project.

Introduction to Creating a responsive Data Table

One of the current trends in web design is making your web pages more responsive to the environment they run on. As we all know the screen real estate for mobile phones, tables and desktop browsers are very different. So how do create pages that work well on all these devices with out having to have specific pages. So what can we do with data tables display the complete table with scrolling or scale the complete tables so it fits? Lets face it neither of these are good solutions to the problem.



So with this sample we will show you another way to handle the issue by using CSS media queries. Note that all browsers do not support these(Hello Internet Explorer) but that browsers that do will give your users a much better display of these tables in small view ports.

Sample description

In this sample we will start with just adding a style sheet and specific styles we will take a horizontal data table and display it vertically so that the user can easily see all rows within the table. The transformation of the table is done completely with styles and changes dynamically as the browser windows size changes. Doing this within a style sheet will have a weakness related to the way the column labels are handled. To make this issue more automated we will build a simple Responsive Data Table builder that will dynamically create the styles needed for the labels and add the style sheet. This is a good example how to take a task that is done with a builder and creating a new builder that just extends the functionality of that builder and automates a new task. To get the data for our models we are using the OredersServiceProvider model from the Building Models feature set. The base models were built using our best practices with a service provider and consumer. The consumer model was built using the List and Details Services Consumer model wizard. This model was then changed by adding a Style builder with an CSS added as an Input and the style added into the HEAD tag.


Here is the application running in a browser window where the table fits.


Here is the vertical table when the window is smaller.



So lets take a look at the styles that were added in the style sheet.
We start with a media query that when the width of the screen is less than 600 pixels it will use these styles
@media only screen and (max-width: 600px) {

Next we need to override the styles that are defined in out theme based style sheets so that the tables width works correctly
.gridTable, .vf_view_list, .vf_view_container{ width: 100%; }
form{ width: 100%; }
.displayPageTable{ width: 100%; }

For the split pagger we need to change the minimum width
.lotusui{ min-width: 300px ! important; }

Change the table to work like a block where each cell is on a separate line
/* Force table to not be like tables anymore */
.tableHeadRow, .tableRowOdd, .tableRowEven, .tableCell { display: block; }

The heading are just moved off the screen so screen readers can still access them even though users will not see them
/* Hide table headers (but not display: none;, for accessibility) */
.tableHeadRow { position: absolute; top: -9999px; left: -9999px; }

Set style on the individual columns so they look table like
tr { border: 1px solid #ccc; }
.tableCell { /* Behave like a "row" */ border: none; border-bottom: 1px solid #eee; border-right: none ! important; position: relative; text-align: center ! important ; }

This adds space in each TD to add the labels for the columns that where hidden off the edge of the window
.tableCell:before { /* Now like a table header */ position: absolute; /* Top/left values mimic padding */ top: 3px; left: 6px; width: 45%; padding-right: 10px; white-space: nowrap; text-align: left; }

This adds the labels to each of the fields that are displayed. This is the section that would vary for every table depending on the displayed columns. This is why we will now add a builder that when added to a page that has a data table it will generate this section depending on the fields that are currently in the table
.tableCell:nth-of-type(1):before { content: "Order Id"; }
.tableCell:nth-of-type(2):before { content: "Date Ordered"; }
.tableCell:nth-of-type(3):before { content: "Status"; }
.tableCell:nth-of-type(4):before { content: "Date Shipped"; }
.tableCell:nth-of-type(5):before { content: "Quantity"; }
.tableCell:nth-of-type(6):before { content: "Amount"; }
.tableCell:nth-of-type(7):before { content: "Billing"; }
.tableCell:nth-of-type(8):before { content: "Shipped"; }
.tableCell:nth-of-type(9):before { content: "State"; }
}

If you use other style sheets or templates where the styles for the columns or containers are different than the default theme you might need to add your own style definitions to make sure the container has 100% width if not usually the labels and the data are displayed on top of each other.

To see this behavior in action run the ResponsiveTableWithStyleSheet model in the samples/ResponsiveUI directory and change the window size to be less than 600 pixels.

To handle the case where the width that you want the table to transition at or the columns of the tables vary and you want this automated I created a sample builder that will do this. This builder is a page automation based builder which allows it to get access to the data information about the page. I started by using the builder skeleton to create the initial builder def and builder code which I then modified. I added a couple of builder inputs that would allow the user to specify the minimum width that the media query would become active at this is in the main section of the builder. I also added the responsive style that defaults to the style that we have already looked at in the style sheet sample, excluding the labels and parameterizing the minimum width. Since the builder skeleton doesn't completely support page automation builders I modified the builder def by hand to add a page automation based input that allows you to select a container that the fields are located in.

I also changed the modifier initializer class so that it would work like the other page automation builders.
com.bowstreet.generation.implementation.PageAutomatonModifierBuilderInitialize Next let's look at the the builder itself. The builder extends the style sheet builder to add the styles to the page. It also by using the page automation helper functions to find the columns that are in the currently displayed in the table. The main builder method doBuilderCall saves off the variables that are very helpful to have available within the builder class. It then gathers the needed inputs to generate the correct style sheet. Then after making sure there are styles to add to the page it locates the correct container and processes the fields that are in the container checking that they are visible within the table. While doing this it updates the Responsive Style input with the added column labels and updates the width within the media query. When this is complete it calls the Style Sheet builder setting the inputs for it so the style will be added to the page's HEAD tag. This builder is builder order dependent being that any builders that hide columns need to precede this builder in the model.

To see this behavior in action run the ResponsiveTableWithBuilder model in the samples/ResponsiveUI directory and change the window size to be less than 600 pixels.

Resources

Tutorial Creating a custom builder


http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Tutorial_Creating_a_custom_builder

Creating Your Application's UI
http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Creating_Your_Applications_UI


Developing Web Applications for Smartphones and Tablets with IBM Web Experience Factory
http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Developing_Web_Wpplications_for_Smartphones_and_Tablets_with_IBM_Web_Experience_Factory
expanded Attachments (1)
collapsed Attachments (1)
File TypeSizeFile NameCreated On
application/x-zip 11 KB ResponsiveTable.zip 3/22/12 11:07 AM
expanded Versions (12)
collapsed Versions (12)
Version Comparison     
VersionDateChanged by              Summary of changes
12Jun 20, 2012 1:16:40 PMGarry Sager  IBM contributor
11Apr 13, 2012 7:13:18 AMGarry Sager  IBM contributor
9Apr 12, 2012 2:43:08 PMRob Flynn  IBM contributor
8Mar 22, 2012 11:07:40 AMGarry Sager  IBM contributor
This version (7)Mar 22, 2012 11:06:59 AMGarry Sager  IBM contributor
6Mar 22, 2012 11:00:40 AMGarry Sager  IBM contributor
5Mar 22, 2012 10:53:06 AMGarry Sager  IBM contributor
4Mar 22, 2012 10:49:10 AMGarry Sager  IBM contributor
3Mar 22, 2012 10:34:41 AMGarry Sager  IBM contributor
2Mar 22, 2012 10:19:50 AMGarry Sager  IBM contributor
1Mar 21, 2012 2:36:26 PMGarry Sager  IBM contributor
1Mar 21, 2012 3:28:10 PMGarry Sager  IBM contributor
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • BlogsIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use