cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • We’re improving the Learn JMP page, and want your feedback! Take the survey
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