cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
tbidwell
Level III

Appending to a Col List Box is not working

I have tried the script below on both JMP 17.1 and JMP 18.0.  (I'm fairly sure it's me and not a bug).  I am having the user select their table from any of their open tables and then choose a Y column, X column and a Grouping column in the form of Col List Boxes.  The issue is that the script only works for the last table in the Combo Box.  It won't work for any of the first 2 tables shown in my example below.  When you press any of the buttons ("Y col", "X col" or "Group col") it doesn't fill in the selected columns you've chosen.  BUT, it does work if you select the last table in the drop-down list.  Any ideas would be appreciated.  BTW, I am trying the loosely follow the scripting in the Example 3 of the Scripting Index for Col List Boxes.

 

names default to here(1);

dt.crops	= open("$sample_data\crops.jmp");
dt.bigclass	= open("$sample_data\big class.jmp");
dt.cars 	= open("$sample_data\cars.jmp");

windowList = get window list(type("data tables")) << get window title();
insert into(windowList, "Choose", 1);	//make the user change the combo box to one of the tables

nwSelect = new window("Choose table and columns", <<modal,
	v list box(
		vlb = v list box(
			panel box("Select table",
				cb_openwin = combo box(
					windowList, 
					dt = data table(cb_openwin << get selected);
					colNames = dt << get column names; 
					try(remove from(vlb,2));  		//remove a previous choice if the combo box changes
					vlb << append(
						pb = panel box("Select Y and X",
							h list box(
								clbCols = Col List Box(data table(dt), all),
								v list box(
									button box("Y col",
										clbYcol << append( clbCols << get selected);
									),
									button box("X col",
										clbXcol << append( clbCols << get selected);
									),
									button box("Group col",
										clbGcol << append( clbCols << get selected);
									),
								),
								v list box(
									clbYcol = Col List Box( maxitems(1), n lines(1) ),
									clbXcol = Col List Box( maxitems(1), n lines(1) ),
									clbGcol = Col List Box( maxitems(1), n lines(1) ),
								),
							),
						),	
					);
				),
			),			
		),
		h list box(
			button box("OK",
				YcolList = clbYcol << get items;
				XcolList = clbXcol << get items;
				GcolList = clbGcol << get items;
			),
			bbc = button box("Cancel"),
		),
	),
);

//close window if Cancel is pressed
if( nwSelect == {Button(-1)}, stop() );
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Appending to a Col List Box is not working

The Active data table is not being set when a table is selected that is not the most recent table loaded.  Add the following line after the line

colNames = dt << get column names;
Current Data Table( dt );

That will set the active data table to the table selected from the combo box

Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Appending to a Col List Box is not working

The Active data table is not being set when a table is selected that is not the most recent table loaded.  Add the following line after the line

colNames = dt << get column names;
Current Data Table( dt );

That will set the active data table to the table selected from the combo box

Jim
tbidwell
Level III

Re: Appending to a Col List Box is not working

@txnelson , Thank you!