cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

Column Selection issue

I am creating a visualization, storing all open file names in a listbox. I then want to select a specific file and display all numeric columns from that file into a colListBox. Oddly, this seems to work only for a file I created myself and not for two additional files from the sample directory. I tried setting the table of choice to the 'current datatable' but I am unable to figure out how to switch columns when I switch table. 

Currently it loads the columns for my defects.jmp table and not the others. 

 

ns = newNameSpace();

// Get some Data
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );		// JMP Library.
dt1 = Open( "$SAMPLE_DATA/Football.jmp" );		// JMP Library.
dt1 = Open( "defects.jmp" );					// Troy Local File.

// Get a list of open files
openDTs = {};
for(i=1, i<= nTable(), i++, 
	insertInto(openDTs, dataTable(i))
);
	
// Create File and Column Selector
selectionWindow = newWindow("Col Selection Test",	
	ns:tableBox = listBox("", << setwidth(200), << setNLines(5), maxSelected(1), 
		selectedTable = (ns:tableBox << getSelected)[1];
		currentDatatable(dataTable(selectedTable));
		colList = dataTable(selectedTable) << getColumnNames("Numeric");
		show(colList);
		ns:columnBox << setItems(colList);
	);
	ns:tableBox << setItems(openDTs);
	ns:columnBox = colListBox({}, width(177), << setNLines(5), maxSelected(1));
	hListBox(ns:tableBox, ns:columnBox);
);

When I select 'defects' I get the following which is the desired result

MarginalLlama65_0-1747699180058.png

 

However, subsequent selections of the other tables do not populate the columns

MarginalLlama65_1-1747699226428.png

 

defects.jmp table

MarginalLlama65_2-1747699332661.png

 

I've tried various options but nothing seems to work??? Weird. 

Any suggestions?

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Column Selection issue

You will have to replace Col List Box as it will refer to specific data table

Names Default To Here(1);

ns = New Namespace();

Open("$SAMPLE_DATA/Big Class.jmp");
Open("$SAMPLE_DATA/Football.jmp");
Open("$SAMPLE_DATA/Cars.jmp");

dts = Get Data Table List() << get name;
	
selectionWindow = New Window("Col Selection Test",
	H List Box(
		lb = List Box(
			dts,
			<< Set Width(200),
			<< Set NLines(5),
			maxSelected(1),
			sel_vals = lb << Get Selected;
			If(N Items(sel_vals) > 0,
				(clb_collector << Child) << Delete Box();
				clb_collector << Append(
					clb = Col List Box(Datatable(sel_vals[1]),
						<< Set Items(Data Table(sel_vals[1]) << Get Column Names("Numeric", "String")),
						<< Set Data Type("Numeric"),
						width(177), 
						<<setNLines(5),
						maxSelected(1)
					)
				);
			);
		),
		clb_collector = V List Box(
			clb = Col List Box(Current Data Table(),
				<< Set Data Type("Numeric"),
				<< Set Items(Current Data Table() << Get Column Names("Numeric", "String")),
				width(177), 
				<<setNLines(5),
				maxSelected(1)
			)
		)
	);
);
lb << Set Selected(Contains(dts, Current Data Table() << get name));
Write();
-Jarmo

View solution in original post

Re: Column Selection issue

Awesome, thanks Jarmo.

Delete and re-append. Why didn't I think of that.

Also, I wasn't aware of function 'Get Data Table List()' which is very handy :)

 

Thanks for the quick reply.

 

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Column Selection issue

You will have to replace Col List Box as it will refer to specific data table

Names Default To Here(1);

ns = New Namespace();

Open("$SAMPLE_DATA/Big Class.jmp");
Open("$SAMPLE_DATA/Football.jmp");
Open("$SAMPLE_DATA/Cars.jmp");

dts = Get Data Table List() << get name;
	
selectionWindow = New Window("Col Selection Test",
	H List Box(
		lb = List Box(
			dts,
			<< Set Width(200),
			<< Set NLines(5),
			maxSelected(1),
			sel_vals = lb << Get Selected;
			If(N Items(sel_vals) > 0,
				(clb_collector << Child) << Delete Box();
				clb_collector << Append(
					clb = Col List Box(Datatable(sel_vals[1]),
						<< Set Items(Data Table(sel_vals[1]) << Get Column Names("Numeric", "String")),
						<< Set Data Type("Numeric"),
						width(177), 
						<<setNLines(5),
						maxSelected(1)
					)
				);
			);
		),
		clb_collector = V List Box(
			clb = Col List Box(Current Data Table(),
				<< Set Data Type("Numeric"),
				<< Set Items(Current Data Table() << Get Column Names("Numeric", "String")),
				width(177), 
				<<setNLines(5),
				maxSelected(1)
			)
		)
	);
);
lb << Set Selected(Contains(dts, Current Data Table() << get name));
Write();
-Jarmo

Re: Column Selection issue

Awesome, thanks Jarmo.

Delete and re-append. Why didn't I think of that.

Also, I wasn't aware of function 'Get Data Table List()' which is very handy :)

 

Thanks for the quick reply.

 

Recommended Articles