cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
GgGgGg2024
Level II

How do I proceed after selecting something from a combo box?

 //fruit is a row in my table
 nw = New window ("Select fruit",
 cb = combo box ("apple", "Mango", "Banana")
 cb << Set Selected,
 << Set Width (20),
 //Here I select apple
 Button Box ("OK",
 	table1 << SelectWhere(:fruit!=apple) << Delete Rows;
 ) )

How do I proceed with the analyses by only selecting data corresponding to 'apple'

 

Here is what I want from this code:

1, I first make a combo box

2. Select apple from the combo box

3. Once I click "OK" I should have the other rows deleted and only rows with apple left.

2 REPLIES 2
mmarchandTSI
Level V

Re: How do I proceed after selecting something from a combo box?

You could do something like this.

 

table1 = New Table( "Kind of Fruity",
	Add Rows( 6 ),
	New Column( "fruit", Character, "Nominal", Set Values( {"Apple", "Banana", "Mango", "Apple", "Apple", "Banana"} ) ),
	New Column( "Condiment",
		Character,
		"Nominal",
		Set Values( {"Peanut Butter", "Ketchup", "Cayenne Pepper", "Chocolate Fudge", "Caramel", "Salt"} )
	)
);
nw = New Window( "Select fruit",
	cb = Combo Box( {"Apple", "Mango", "Banana"} ),
	Button Box( "OK",
		table1 << Delete Rows( table1 << Get Rows Where( :fruit != (cb << Get Selected) ) );
		nw << Close Window;
	)
);
jthi
Super User

Re: How do I proceed after selecting something from a combo box?

You need slight modifications to your script:

  • You need to use list to input values to combo box
  • You should get the value which was selected by user (usually within OK button) using << get selected
  • You should perform the check dynamically based on the user selection in your Select Where statement

@mmarchandTSI answer already has answer for these problems so I provide a bit different solution in which you get the values based on your fruit column to the combo box, demonstrate how to set specific fruit and use << get rows where instead of select where

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("fruit",
		Character,
		"Nominal",
		Set Values({"apple", "Mango", "Banana", "apple", "Banana", "Kiwi"})
	)
);
Summarize(dt, fruits = By(:fruit));

nw = New Window("Select fruit",
	cb_fruits = Combo Box(fruits),
	Button Box("OK",
		sel_fruit = cb_fruits << get selected;
		nok_fruit_rows = dt << Get Rows Where(:fruit != sel_fruit);
		dt << Delete Rows(nok_fruit_rows); // note that fruits variable isn't updated
		nw << Close Window; 
	),
	cb_fruits << Set(Contains(fruits, "Kiwi"));
);
-Jarmo

Recommended Articles