About Duffbert...

Duffbert's Random Musings is a blog where I talk about whatever happens to be running through my head at any given moment... I'm Thomas Duff, and you can find out more about me here...

Email Me!

Search This Site!

Custom Search

I'm published!

Co-author of the book IBM Lotus Sametime 8 Essentials: A User's Guide
SametimeBookCoverImage.jpg

Purchase on Amazon

Co-author of the book IBM Sametime 8.5.2 Administration Guide
SametimeAdminBookCoverImage.jpg

Purchase on Amazon

MiscLinks

Visitor Count...



View My Stats

« Book Review - The Non-Designer's Type Book by Robin Williams | Main| The DVD of our Lotusphere session arrived today! »

Show And Tell Thursday: Dynamic Sorting Of Data On A Document...

Category Show And Tell Thursday


Some time back, I inherited an application that tracked milestones on a project.  Each milestone line contained milestone name, start date, original planned end date, current end date, and actual end date fields.  Not so bad, except there were 70 lines of this data!  Five fields times 70 lines...  350 fields!  The only redeeming factor is how the fields were named...  Milestone_0, Milestone_1, and so on up through Milestone_69.  At least you could access them programmatically.

Now the users made a request that really worried me.  They wanted to be able to sort the 70 lines of data on any one of the five field values.  So if they wanted the list to be sorted in start date order, all the data on the document needed to be rewritten in those 350 fields in the proper order...  What to do?

What I ended up doing was somewhat creative (for me, at least!).  I would ask the user to specify which column should be the sort value, and then I would build an array of that data concatentated by a caret ( ^ ).  The lead value in the array element would be the value found in the specified sort column, followed by the five fields in each line.  I then used a sort routine stolen from somewhere that would sort an array.  Since my sort value was at the front of the array, the sorting was no problem.  Once the array was sorted into the new order, I simply read the array and replaced the field values.  Voila...  dynamic sorting at the user's request!

Here's the code I used to accomplish this hack...

Comments

Gravatar Image1 - I was lucky to not be using 4.5 on this particular application... :). R5 was the client in use, and ND6.x was a far-off dream. :)

Gravatar Image2 - Very nice.
If this was in ND6, I would have used formula. Personally I always like formula when working with list, because Lotus makes it so easy to work with them like the @Sort function. The code would have had 2 @For loops (one to build the list and the other to extra the data from the list) and the use of @Sort between the for loops.

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Want to support this blog or just say thanks?

When you shop Amazon, start your shopping experience here.

When you do that, all your purchases during that session earn me an affiliate commission via the Amazon Affiliate program. You don't have to buy the book I linked you to (although I wouldn't complain!). Simply use that as your starting point.

Thanks!

Thomas "Duffbert" Duff

Ads of Relevance...