cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with 2 Multiple Selection List Boxes add/remove function

former_member76372
Participant
0 Kudos

Hi Experts,

I am new to this thing, I've been searching all over the web to find a similar issue with mine but no luck.

So I have 2 List boxes in my interactive forms,

(1) The first List box contains all entries by default when opening the form.

(2) The second list box 'will' contain all the entries being selected from the first list box

(3) I have 2 pushbuttons for Add and Remove - If you are familiar with ALV, when you try to choose a field or modify a report Layout, this is what I am trying to achieve

Now the Add button (Button1) may not seem to have a problem, as in the mouseDown event, I have inserted this code:

ZTEST.#subform[0].Button1::mouseDown - (FormCalc, client)

ZTEST.#subform[0].ListBox2.addItem(ZTEST.#subform[0].ListBox1.rawValue)

while (ZTEST.#subform[0].ListBox1.selectedIndex ne "-1")  do

(ZTEST.#subform[0].ListBox1.deleteItem(ZTEST.#subform[0].ListBox1.selectedIndex))

endwhile

this actually works fine as it transfers, and deletes the item being selected (either single or multiple)

however in the Remove Button (Button2) using the same chunk of code as per above, I cannot pass back the items correctly back from ListBox2 to ListBox1.

It seems when I do multiple selection, it treats all the multiple selected items as one Selectedindex in ListBox2. However, when I individually select each item and add, it is working fine.

Is there anything you can suggest? I wanted to explore more, but I am a bit short with time as I am abap by nature.

Thanks a lot and looking forward to your respoonses.

Accepted Solutions (1)

Accepted Solutions (1)

former_member76372
Participant
0 Kudos

This is OK. I have managed to find the solution myself. Not with formcalc but using Javascript.

I have one Button (Add/Remove) buttons, So the program will automatically check which ListBoxes are being selected:

Choose MouseDown events in Add/Remove buttons:

if

(this.ListBox1.selectedIndex>-1) // check if ListBox1 has been selected or at least one has been selected

{

var lt1 = (this.ListBox1.items.nodes.length); //get the number of items in the list to create a loop

for(var j=lt1-1;j>=0;j--) //iterate base on the length of the list

{

if (this.ListBox1.getItemState(j)==true ) //check whether this item is being chosen

{

var cEntry = this.ListBox1.getDisplayItem(j);//get the display item instead of the index number

this.ListBox2.addItem(cEntry) //add this item to the next listbox

this.ListBox1.deleteItem(j); / delete this item being selected(as it is already transferred)

//else

//{

//(xfa.host.messageBox("No Entry Selected"));

//}

//}

}

}

}

//The next chunk of code is just a reversal of the code above from ListBox2 to ListBox1

if

(this.ListBox2.selectedIndex>-1)

{

var lt1 = (this.ListBox2.items.nodes.length);

for(var j=lt1-1;j>=0;j--)

{

if (this.ListBox1.getItemState(j)==true )

{

var cEntry = this.ListBox2.getDisplayItem(j);

this.:ListBox1.addItem(cEntry)

this.ListBox2.deleteItem(j);

}

}

}

---------------------------------------------------------------------------------------

Now I am doing the sort thing

Answers (0)