Data Table (HUH) – What is it good for?

With apologies to Edwin Starr*, this is a question that I’m pondering.

I haven’t heard much about the Data Table control (aside from the coverage in the Mastering XPages book), but I’m in the process of working through several display controls in XPages to make sure I know them well enough to make the best decision for each application that I develop. (Foreshadowing alert — look for information on additional controls in the near future.)

Creating a Data Table

If you drag a data table control onto an XPage or custom control, this is what you get by default:

<xp:dataTable id="dataTable1" rows="30">
  <xp:column id="column1"></xp:column>
  <xp:column id="column2"></xp:column>

There are three rows displayed in the XSP editor for the header, body, and footer, respectively.

It’s essentially the shell of a table that you need to manually configure by adding your own controls and binding them. This makes it much more like a repeat control. Compare that to a view panel, where you are prompted for a data source and all of the selected columns are set up and bound automatically.

On the Data Table subtab of the Properties panel, you can select a data source (view, document, or object data source, if you have the extension library or UP1), set the number of rows to display (Repeat limit), set the variable to programmatically access each row (Collection name), and set the variable to access the row number (Index name).


The Collection name is necessary because there would be no other way to access each row to bind data. You can use expression language or SSJS to bind the values to underlying view columns, but, according to the Mastering XPages book, view columns with dollar signs ($) in the name are problematic with EL, so watch out for that. For cases when you can use EL, it’s easy enough to just pick the column name based on the Collection name variable.


On the Display subtab of the Properties panel, you only have two options: Show pager in header and Show pager in footer. Once you select one or both of those options, you will get a pager control for the control, which you can modify.


On the All Properties subtab of the Properties panel, under ‘data’, you can see that there are very few options for working with the data. No way to search or filter or set a start key.



The Default Result

Here’s what it looks like when I add two labels and two controls bound to view columns, along with a pager in the header:


My Perspective

So, it looks to me like this is a lightweight repeat control-ish way to display some view data.

You have more flexibility with the UI because you’re not locked into view columns, but it will be a manual undertaking. Repeat controls also have that flexibility and there’s a lot you can do to customize view panel columns (see this blog post or this episode of NotesIn9 for more information), so I’m not sure where this control would come into play.

The lack of options for working with the data makes it hard for me to see how this could be useful other than with a very small set of information.

Use Cases?

If you’ve ever used a data table, let me know. I’m curious to hear the use case.

* (This reference is in no way an endorsement of the song or its message — the hook just popped into my head. If you recognize it, it’s probably stuck in yours now, too!)


18 responses to “Data Table (HUH) – What is it good for?”

  1. Frank van der Linden says :

    In my opinion, Data Tables are more usefull versus repeat controls when there data inside which can be updated.
    My experience is that Repeat Controls are heavily cached, so sometime it is hard to update the underlying collection.
    When that is the case I use the Data Table

  2. DavidLeedy (@DavidLeedy) says :

    When you want a repeat that looks like a table you MIGHT be better off with Data Tables. It’s quick and easy to get going really. Creating tables inside repeats is such a pain trying to deal with the header and footer facets and it looks horrible in designer.

    But if your table gets fancy with the layout at all then I’d avoid data tables for repeat controls. Especially if you want to hide and unhide rows based on an event or condition.

  3. Mark Hughes says :

    Don’t forget you get allot of great css functionality with data tables vs repeats, example Row Classes Column Classes

    Also a 1 column datatable is a repeat with a header and a footer 😉

  4. John Jardin (@John_Ukuvuma) says :

    I’m very fond of Data Tables in the sense that I use them a lot when working with Java ArrayList Objects.

    I can’t say I really understand the pros/cons of using a Repeat vs a Data Table other than what’s been mentioned here.

  5. Jesse Gallagher says :

    I use dataTables all the time for data not coming (directly, at least) from a view. Basically, whenever I want to display repeatable data in a table (an array of IDs, a List of Maps, etc.), I aim to do it in a dataTable first and only fall back to a repeat control if the structure gets complex. They’re not ALWAYS the best fit, but they can save you a lot of hassle sometimes.

  6. Dan Soares says :

    I just finished working with populating a datatable with a Java array list from a JDBC query. Took me a while to figure it out but I eventually got there with the help of the Lotus community. I suppose I could have used a Repeat control too. I might write a short article on what I’ve learnt sometime soon.

  7. John Jardin (@John_Ukuvuma) says :

    Hi Brad. Keep an eye on my Blog in the next 2-3 weeks. I’ll be blogging a Video Tutorial regarding integrating XPages with DB2 and will be using a Data Table which binds to a Java ArrayList.

    • Brad Balassaitis says :

      Excellent — looking forward to it!

    • Andres Rodriguez says :

      Hi John, could me a favor and share with me the video link that you refer, I am very interested in seeing it, because right now, I’m trying to access the selected checkbox in a list that is implemented on a xpages datatable, the list is read from a table that is in DB2, John thank you for the help you can give me, please excuse my English.

  8. Fredrik Stöckel says :

    I recently used a DataTable (connected to a javaobject) to display/manage the content in a shopping-cart. Very easy to create summary/total cost rows and so on.

  9. swapnil says :

    Yeah I Found Datatable are very effective. All thanks to you. If I add checkbox in the row data table (so that It will repeat same as we have in view panel). How can I get selected document’s ID on button click. Cause I have to implement delete functionality. Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: