Re-arranging order of content in a listbox field

I’m trying to develope a solution (in a Notes form) where the UI consist of two listbox fields. One contains multi-value in a listbox and the user can select a set of choices and press a button to move the selected choices over to another listbox field (multi-value).

I’ve implemented this feature and it work perfect, however my problem is that I want to provide the user two buttons to re-arrange the content of the “target” list box. The user should be able to move selected choices UP, or DOWN inside the list box itself.

Any ideas???

  • linked-lists?

  • arrays?

  • ???

Subject: Re-arranging order of content in a listbox field

One proposal if the number os elements is high (more than 8).

use to buttonos: ORDER SET

and a new field: ORDERED

Supose the field to reorder is CATS

Formula for button ORDER:

a:= @prompt([OKCANCELLISTMULT]; “Order”; “Select the options to move at end of ORDER:”; “”; @trim( @replace( CATS; ORDERED; “”)));

@if( @text(a) = “”|“1”; @return( “”);“”);

field ordered := ordered : a;

1

Formula for SET button:

field CATS := @trim(cats:ordered);

field ordered := “”;

1

It is one aproach. If its not valid, let me know it with more details of yor problem.

Subject: RE: Re-arranging order of content in a listbox field

Thank you for your response, but I need to support re-ordering within the choices inside the list box.

Ex of the list content;

valueA

valueB

valueC

valueD

valueE

If a user select valueC and press the “Up” button the list should look like;

valueA

valueC

valueB

valueD

valueE

OK.

To even complicate it further, the user should be able to select multiple-values and move them one step up or down.

Subject: RE: Re-arranging order of content in a listbox field

Henrik,

How r u updating ur second list? If by using some other field! u could play with the array (index). Get the selected value from second list and get its position and move it to array (position-1) and also rearrange other values of that array accordingly.

:slight_smile:

Subject: RE: Re-arranging order of content in a listbox field

OK, here is a more detailed description.

I have an array that looks like;

(0) valuea

(1) valueb

(2) valuec

(3) valued

(4) valuee

(5) valuef

And I also have an array of indexes. This array is containing the indexes of the selected values in the first array and looks like;

(0) 2

(1) 3

(2) 5

This means that I would like to move valuec, valued, and valuef up one step so the resulting order would be like;

(0) valuea

(1) valuec

(2) valued

(3) valueb

(4) valuef

(5) valuee

I have trouble with an algorithm for this reordering problem.

Subject: Re-arranging order of content in a listbox field

Another aproach: Only need a button “MOVE TO END” wuth this formula:

a:= @prompt([OKCANCELLISTMULT]; “Move to end”; “Select options to move to end”; @subset( cats; 1); cats);

@if( @text(a) = “”|“1”; @return( “”); “”);

field cats := @trim( @replace( cats; a; “”)) : a;

1

Or the same with a buttom: MOVE TO TOP:

a:= @prompt([OKCANCELLISTMULT]; “Move to end”; “Select options to move to end”; @subset( cats; -1); cats);

@if( @text(a) = “”|“1”; @return( “”); “”);

field cats := a : @trim( @replace( cats; a; “”)) ;

1

Assume CATS is the name of your field.

Subject: Re-arranging order of content in a listbox field

I think has obtained what you want.I have tested it in a databas and it run!

It is difficult to explain here.

You need another field (field1):

  • Checkbox.

  • Editable.

  • Options: YourField

  • Refresh Fields on keyword changes

  • Refresh choices on document refresh

  • Defaulkt value “”

  • It can be hide on read.

Near put a bottom labeled “Up Selected 1 level” with this formula:

a:= @Subset( @Member( FIELD1; YOURFIELD); 1);

@If( a = 1; @Return( “”); “”);

q := @If( a > 2; @Subset( YOURFIELD; a-2) ; “”) : FIELD1 ;

q2 := @Trim( @Replace( YOURFIELD; q; “”));

FIELD YOURFIELD := q : q2;

@Command([ViewRefreshFields])

If you want the test database, send a message asking it to teseoteseo@yahoo.com.