cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
UserID16644
Level V

Add additional values to list using col list box

Is it possible that an existing list would have an additional data from col list box?

For example: Fruits = {"apple", "mango", "strawberry"}

Then, when user picked banana, orange from the col list box, it will be added to the fruits list. 

 

I tried using Fruits = get items but only the initial list values are initialized. Pls help

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Add additional values to list using col list box

Here are 2 examples.  The first one is using a Col List Box.  It requires the additional fruit choices to be column names, so that they will show up in the Col List Box as choices to be added to the Fruits list.

Names Default To Here( 1 );
dt=new table("New Fruits",
	new column("Bananas"),
	new column("Oranges")
);
Fruits = {"apple", "mango", "strawberry"};
New Window( "Example",
	lb = col List Box(dt,all,
		width( 200 ),
		max selected( 1 ),
		nlines( 6 ),
		selList = lb << get selected;
		locList = lb << get selected indices;
		If( Contains( Fruits, selList[1] ) == 0,
			Insert Into( Fruits, selList[1] )
		);
		lb << set selected(locList[1],0);
		show(Fruits);
	)
);

This seems to be an inefficient way to code this, unless the choices you want to make are actually column names.  If they are not column names that need to be selected, then by using just a List Box() will work just fine

Names Default To Here( 1 );
Fruits = {"apple", "mango", "strawberry"};
New Window( "Example",
	lb = List Box(
		{"Banana", "Orange"},
		width( 200 ),
		max selected( 1 ),
		nlines( 6 ),
		selList = lb << get selected;
		locList = lb << get selected indices;
		If( Contains( Fruits, selList[1] ) == 0,
			Insert Into( Fruits, selList[1] )
		);
		lb << set selected(locList[1],0);
		show(Fruits);
	)
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Add additional values to list using col list box

Here are 2 examples.  The first one is using a Col List Box.  It requires the additional fruit choices to be column names, so that they will show up in the Col List Box as choices to be added to the Fruits list.

Names Default To Here( 1 );
dt=new table("New Fruits",
	new column("Bananas"),
	new column("Oranges")
);
Fruits = {"apple", "mango", "strawberry"};
New Window( "Example",
	lb = col List Box(dt,all,
		width( 200 ),
		max selected( 1 ),
		nlines( 6 ),
		selList = lb << get selected;
		locList = lb << get selected indices;
		If( Contains( Fruits, selList[1] ) == 0,
			Insert Into( Fruits, selList[1] )
		);
		lb << set selected(locList[1],0);
		show(Fruits);
	)
);

This seems to be an inefficient way to code this, unless the choices you want to make are actually column names.  If they are not column names that need to be selected, then by using just a List Box() will work just fine

Names Default To Here( 1 );
Fruits = {"apple", "mango", "strawberry"};
New Window( "Example",
	lb = List Box(
		{"Banana", "Orange"},
		width( 200 ),
		max selected( 1 ),
		nlines( 6 ),
		selList = lb << get selected;
		locList = lb << get selected indices;
		If( Contains( Fruits, selList[1] ) == 0,
			Insert Into( Fruits, selList[1] )
		);
		lb << set selected(locList[1],0);
		show(Fruits);
	)
);
Jim