Choose Language Hide Translation Bar
Highlighted
anne_sa
Level V

Is it possible to associate a ColLIstBox with two different data tables?

Hello everybody,

 

I have a tool which is based on two different data tables.

On the launch  interface, the user needs to specify some columns coming from the first table, some columns coming from the second tables and also some columns which can be either in the first or second table.

Here is a small example to reproduce my problem:

 

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Cities.jmp" );
new window("Test",
	hlistbox (
		panel box ("Table 1",
			hlist box(
				collistbox(data table(dt1),all),
				vlist box(
					text box("Select a variable from table 1"),
					CL1 = collistbox(data table(dt1),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Table 2",
			hlist box(
				collistbox(data table(dt2),all),
				vlist box(
					text box("Select a variable from table 2"),
					CL2 = collistbox(data table(dt2),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Last variable",
			vlist box(
				text box("Select a variable from table 1 or table 2"),
				CL3 = collistbox(maxitems(1),nlines(1))
			)
		)
	)
)

In CL3 I would like to be able to put either a column of the first table or a column from the second. I am not sure if it is feasible to that with a ColListBox object. Otherwise do you know if there is another way to do that?

 

Thanks in advance for your help!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Is it possible to associate a ColLIstBox with two different data tables?

Here is a little trick that I have used in the past for other issues, but it works well.  I have modified your code to create a new, private data table, that has all columns in it, but no data.  It allows you to select columns from either of the Col List Box()s.

names default to here(1);

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Cities.jmp" );
dt3 = dt1 << concatenate(private,dt2);
dt3 << delete rows(index(1,nrows(dt3)));
nw = new window("Test",
	hlistbox (
		panel box ("Table 1",
			hlist box(
				collistbox(data table(dt1),all),
				vlist box(
					text box("Select a variable from table 1"),
					CL1 = collistbox(data table(dt1),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Table 2",
			hlist box(
				collistbox(data table(dt2),all),
				vlist box(
					text box("Select a variable from table 2"),
					CL2 = collistbox(data table(dt2),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Last variable",
			vlist box(
				text box("Select a variable from table 1 or table 2"),
				CL3 = collistbox(data table(dt3),maxitems(1),nlines(1))
			)
		)
	)
);

nw << on close( close(dt3,nosave));
Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Is it possible to associate a ColLIstBox with two different data tables?

Here is a little trick that I have used in the past for other issues, but it works well.  I have modified your code to create a new, private data table, that has all columns in it, but no data.  It allows you to select columns from either of the Col List Box()s.

names default to here(1);

dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Cities.jmp" );
dt3 = dt1 << concatenate(private,dt2);
dt3 << delete rows(index(1,nrows(dt3)));
nw = new window("Test",
	hlistbox (
		panel box ("Table 1",
			hlist box(
				collistbox(data table(dt1),all),
				vlist box(
					text box("Select a variable from table 1"),
					CL1 = collistbox(data table(dt1),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Table 2",
			hlist box(
				collistbox(data table(dt2),all),
				vlist box(
					text box("Select a variable from table 2"),
					CL2 = collistbox(data table(dt2),nlines(1),maxitems(1))
				)
			)
		),
		panel box ("Last variable",
			vlist box(
				text box("Select a variable from table 1 or table 2"),
				CL3 = collistbox(data table(dt3),maxitems(1),nlines(1))
			)
		)
	)
);

nw << on close( close(dt3,nosave));
Jim

View solution in original post

Highlighted
anne_sa
Level V

Re: Is it possible to associate a ColLIstBox with two different data tables?

Thanks @txnelson that's really a nice trick! It may require a few adjustments for some specific cases otherwise I think it is exactly what I was looking for!

Article Labels