cancel
Showing results for 
Search instead for 
Did you mean: 

Lumira Designer 'next and previous' Button on dynamic List.

spiegler_s
Explorer
0 Kudos

Hi @ all.

I struggle with the following requirement.

We try to load a Listbox with Items on the start of an application.

The Listbox item affected an chart as filter.

Now i want to change the selected entry in the listbox over an button.

like an next button. When the user click on it the next entry should get selected.

Maybe someone can help me.


I already tried to create an array and load the elements from the List. But it doesnt work.

Thanks for your help.

Best regards

Accepted Solutions (1)

Accepted Solutions (1)

MustafaBensan
Active Contributor

Hi Sebastian,

Here is what I suggest:

1. Create the following Global Variables

ItemIndex int
ListItems string array
MaxItems  int

2. In the Application OnStartup event load the list items into an array first and then loop through this array to load the listbox, using the following code:

ListItems = ['K1,Item 1', 'K2,Item 2','K3,Item 3','K4,Item 4'];
MaxItems = ListItems.length - 1;
ItemIndex = 0;

var Item = [''];
Item.pop();

ListItems.forEach(function(item, index) {
  Item = item.split(',');
  
  LISTBOX.addItem(Item[0], Item[1]); 
   
});

The list items don't have to be hardcoded. If you are using a member list from DS.getMembers() then simply loop through the members and add the comma separated Key Text combinations using ListItems.push().

3. Apply the following code in the On Click event of the Left button/icon:

if (ItemIndex > 0)

	{
	
		ItemIndex = ItemIndex - 1;	
	
	} 
	
else 

	{
	
		ItemIndex = MaxItems;
	
	}

LISTBOX.setSelectedValue(ListItems[ItemIndex].split(',')[0]);

4. Apply the following code in the On Click event of the Right button/icon:

if (ItemIndex < MaxItems)

	{
	
		ItemIndex = ItemIndex + 1;
	
	} 

else 

	{
	
		ItemIndex = 0;
	
	}

LISTBOX.setSelectedValue(ListItems[ItemIndex].split(',')[0]);

Let me know if you have any questions.

Regards,

Mustafa.

Answers (1)

Answers (1)

spiegler_s
Explorer
0 Kudos

Hi Mustafa.

Thanks. Thats perfect.

Already struggeling with the getMembers loop.

Maybe you can help me there.

I put a loop on the top.

But it says Cannot convert from members to String.



var test = DS_1.getMembers("BRANCH", 100);

var test2 = [''];

test.forEach(function(element, index) {

test.push(element);

test = test2;

});

ListItems = test2;

Maxitems = ListItems.length - 1;

ItemIndex = 0;

var Item = [''];

Item.pop();

ListItems.forEach(function(item, index) {

Item = item.split(',');

LISTBOX_1.addItem(Item[0], Item[1]);

});

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

Thanks for your help. I am really new in it.

Best regards

Sebastian

triasadi_pt
Discoverer
0 Kudos
var test = DS_1.getMembers("BRANCH", 100);
var test2 = [''];
test.forEach(function(element, index) {
test.push(element);
test = test2;
});

Hi,

Try using

test.push(element.text);

Thanks,