The great benefit of the collapsible detail section in the Data View control is that you can make a lot more information available in the view, but not clutter the screen with it unless the user requests it. I’ve had several cases where I’ve created a repeat control in the detail section and used it to display information related to the main document. In this post, I’ll show how to do it.
Data View Series
- Part 1 – Overview
- Part 2 – Creating a Data View
- Part 3 – Collapsible Details
- Part 4 – Icon Columns
- Part 5 – Pager Add Rows Control
- Part 6 – Pager Save State Control
- Part 7 – Customized Summaries
- Part 8 – Sorting and Filtering
- Part 9 – Multi-Column Layout
Nested Repeat Control
Here’s an example from the NotesIn9 video I did on customizing the Data View control.
The sample database has a list of companies and a list of stock prices documents related to each company. When the user expands a company in the Data View, they see the list of related stock prices (along with a company description).
Here are the steps:
- Set the var property of the data view to provide a handle to each entry
- Create a repeat control in the detail section. (Add a panel or div to the Detail section and add the repeat control within that container.)
- Compute the value of the repeat control (All properties > data > value) to retrieve the ID of the main document and use it to look up related documents to display in the repeat control
Here is the code that populates the repeat control:
var vwPrices:NotesView = database.getView('Prices'); if (rowHandle.isDocument()) { var companyID = rowHandle.getDocument().getItemValueString('CompanyID'); var vecPrices:NotesViewEntryCollection = vwPrices.getAllEntriesByKey(companyID); return vecPrices; } else { return null; }
The key to making this happen is having the ability to retrieve the UNID of the main document when populating the repeat control. In this example, the var property of the Data View is set to rowHandle and it used in line 3 to retrieve the CompanyID.
In line 4, the list of related stock prices is looked up from a view.
In line 5, the viewEntryCollection of price documents is returned to be the source of the repeat control.
At this point, the repeat control has the data and you just need to add computed fields to display it like you would with any repeat control.
