Skip to main content
    Country/region select      Terms of use
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

There was an oft-repeated question in the Notes 6&7 forum this morning, which inspired me to write the attached utility. This is for where you have a table on a form with a field in each cell, and you want to be able to keep the table sorted by one or more columns.

The source file is attached, which you can import into a script library or the globals section of the form or whatever.
To invoke the sorting function, make a call such as:

Call SortATable(uidoc, "Key,DueDate,Comment,OrderAmt", "Key", 5, "_", True)

The arguments, in order, are:
  • A NotesUIDocument (for the document you're editing), or a NotesDocument (if you want to sort data in a back-end document).
  • A comma-delimited list of the fieldnames in the table, minus the numerical suffix designating the row.
  • A comma-delimited list of which of these you want to sort by.
  • The number of rows in the table.
  • The character used to separate the column name from the row number to create the fieldname.
  • True for ascending, False descending.
If the first key field is blank, that row will always drop to the end of the table. The _1 on the fields of the first row are optional (as shown above).

Andre Guirard | 4 August 2008 12:29:51 PM ET | Home, Plymouth, MN, USA | Comments (5)


1) Generalized table-sorting class
Nathan T. Freeman | 8/4/2008 4:25:52 PM

Ugh... Andre, why are you perpetuating this heinous design pattern? :-( The only tool that someone should be using if they need to modify an app that does that is the DELETE key.

2) Generalized table-sorting class
Andre Guirard | 8/4/2008 7:28:31 PM

Nathan, because people are going to do it anyway, and so they might as well do it in the most user-friendly way. And actually, for user-friendliness that design isn't too bad if you provide the sorts of tools that make it easier, like delete row, and so on. At least you can tab thru all the fields, which is nice for accessibility, or click on a value and edit it. Admittedly, it falls short on maintainability and performance, but you can't have everything. Besides, it was something to do while waiting for my compile to finish.

3) Generalized table-sorting class
Rob Goudvis | 8/5/2008 1:18:10 AM

A suggestion for an improvement on this sample could be to have the possibility to sort on any column you like. This easily can be achieved by creating hotspots on each column-header and invoke the function SortATable with the correct parameters from these hotspots.

4) Generalized table-sorting class
Gabriel Amorim | 8/5/2008 7:04:39 AM

It's a very good idea. I'll try to improve more dynamic code at your brillant idea. Thanks for sharing once more, Andre.

5) Generalized table-sorting ... AGENT
Pascal Blancquaert | 9/9/2010 6:33:05 AM

I appreciate the ideas and solutions presented on the topic of table sorting in Lotus Notes ...

However, not being a developer in this field,

my concern would be for a daily usable 'feature' that would allow to sort a table that one so often inserts in any document/email to present information in a structured way.

Is there any e.g. agent available that allows to perform a table sort within a Notes-document, like the sorting in Excel, ie.

- option to use first line as field headers

- option to sort ascending/descending on a sequence of sort-criteria (fields)



 Add a Comment
Comment:  (No HTML - Links will be converted if prefixed http://)
Remember Me?     Cancel

Search this blog 


    About IBM Privacy Contact