Glen Urban August 22 2013 02:39:24 PMIf you have been developing "view" like controls with repeats you will at some point have to find a method to select rows/documents within your repeat.
A common method seems to be the one described in this Notesin9 video. I have used a variant of this widely, using SSJS in the onclick event of a check box to store selected document IDs in a scoped variable. This has worked well but I have experienced performance problems for large sets of data: check boxes became unresponsive and did not keep up with users when selecting multiple rows.
So I wanted to explore an alternative solution. This alternative method uses a check box bound to a java map in a bean. This means that selecting/de-selecting the check box does not fire an event that sends data to the server. The check box is in a custom control and bound to the bean like this:
This allows you to store selected Note IDs, or your own unique IDs. They can be retrieved using a call to the bean like this: SelectedDocs.getSelectedIDs()
A demo DB is attached for those who wish to explore the code further. Please note I have only tested this with Release 9.0
How to Implement in another database
1) Add the package uk.co.norstrong.rowselect to your DB
2) Update faces-config.xml
If you set the scope of the bean to request then it will behave like a standard view control and lose row/document selections when paging in your repeat. If you set the bean scope to view then selections can persist between different pages but you must set the partialExecute property of the pager to false...
3) Add the custom control ccRowSelectCheckBox to your repeat.
It has the following properties:
docID It makes sense to use the NoteID but it could be any unique identifier.
containerID Optional. The ID of the container e.g. a table row or a div. The selectedClass will be applied to this ID.
To get a vector of selected document IDs in SSJS use: SelectedDocs.getSelectedIDs()
To set an individual check box state use: SelectedDocs.setSelectedState(id,boolean);
So far I haven't used this method widely so I wondered if others have used a similar method? And if so have you experienced any issues with it? Any feedback would be gratefully appreciated.
- Comments