Subscribe Bookmark RSS Feed

Multiple data tables open

matt7109

Contributor

Joined:

Jun 9, 2017

Hey, 

I have a script that produces an output of 3 different data tables, each displaying unique data. Upon completion of the script, the 3 tables pop up separatley, bombarding the user with them. Is there anyway these 3 tables can be displayed in neater way, or even all under tha same window?

 

Thanks!

Matt

3 ACCEPTED SOLUTIONS

Accepted Solutions
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

For 'the same window' part, you could try something like:

NamesDefaultToHere(1);

dt1 = Open("$SAMPLE_DATA/Big Class.jmp", Invisible);
dt2 = Open("$SAMPLE_DATA/Bands Data.jmp", Invisible);

win = NewWindow("Both Tables", << OnClose(onCloseScript), 
		PanelBox(dt1 << getName, DataTableBox(dt1)),
		PanelBox(dt2 << getName, DataTableBox(dt2))
	);
onCloseScript = Expr(Close(dt1, NoSave); Close(dt2, NoSave));
Justin_Chilton

Joined:

Aug 27, 2015

Solution

If you wanted a way to show the interactive data tables in the same window, you could use the New Data Box() message to create a DataBrowserBox for each of the tables. See my example below for details.

Names Default To Here( 1 );
// open the tables as invisible
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", invisible );
dt2 = Open( "$SAMPLE_DATA/Bands Data.jmp", Invisible );

// Create a window with both tables shown
New Window( "Both Tables",
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		a = dt1 << New Data Box(), // Returns DataBrowserBox
		b = dt2 << New Data Box()  // Returns DataBrowserBox
	)
);

// Close the side panels for both tables
a << close side panels();
b << close side panels();

The resulting window:

Capture.PNG

Justin
Justin_Chilton

Joined:

Aug 27, 2015

Solution

Hi @matt7109,

The menu and toolbars you see are limited to one per window. You will need to create your own custom behaviors for actions (like save) that would typically be done using the menu or toolbars. 

The below script creates a red triangle menu that will save the data table within the Outline Box. Notice that I turned on the "Data Table List" in the toolbar so that you can see the current data table. With this method, you can still use the menus (Tables, DOE, Analyze, Graph) that will perform actions on the current data table shown in the data table list.

 

Names Default To Here( 1 );
// open the tables as private
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", private );
dt2 = Open( "$SAMPLE_DATA\Bands Data.jmp", private );

// Create a function to create each data table to reduce code redundancy
getDataTableOutlineBox = Function( {dt},
	Eval(
		Eval Expr(
			Outline Box( dt << Get Name, // title of the tab
				dt << New Data Box(), //DataBrowserBox
				// Add scripts to the Red Triangle menu for the Outline Box
				<<Set Menu Script(
					{
						"Save As", // Name of the menu item script
						
						// get path to save the data table
						savePath = Pick File(
							"Save JMP Data Table",
							"",
							{"JMP Files|jmp", "All Files|*"},
							1,
							1,
							Expr( dt << get name ) || ".jmp" // evaluate the name of the table when the menu script is added
						);
						// If the user selected a path, save the table at that path
						If( savePath != "",
							Expr( dt ) << save( savePath )
						); 
					
					}
				)
			)
		)
	)
);

// (optional) Turn on the Data Table list for reports so that you can see what the current data table is
Set Toolbar Visibility( "Data Table List", Report, true );

// Create a window with both tables shown
New Window( "Both Tables",
	Suppress AutoHide( 1 ), // Suppress the auto hide so that the toolbars appear
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		getDataTableOutlineBox( dt1 ),
		getDataTableOutlineBox( dt2 ),

	)
);

Below is a screenshot of the window after clicking on the Red Triangle Menu. 

2017-07-13_12-44-55.png

 

Justin
7 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

You can make them Invisible or Private data tables, or you can Minimize them.  Go to

     Help==>Scripting Index==>Data Table

to see examples of how to do these

Jim
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

For 'the same window' part, you could try something like:

NamesDefaultToHere(1);

dt1 = Open("$SAMPLE_DATA/Big Class.jmp", Invisible);
dt2 = Open("$SAMPLE_DATA/Bands Data.jmp", Invisible);

win = NewWindow("Both Tables", << OnClose(onCloseScript), 
		PanelBox(dt1 << getName, DataTableBox(dt1)),
		PanelBox(dt2 << getName, DataTableBox(dt2))
	);
onCloseScript = Expr(Close(dt1, NoSave); Close(dt2, NoSave));
Justin_Chilton

Joined:

Aug 27, 2015

Solution

If you wanted a way to show the interactive data tables in the same window, you could use the New Data Box() message to create a DataBrowserBox for each of the tables. See my example below for details.

Names Default To Here( 1 );
// open the tables as invisible
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", invisible );
dt2 = Open( "$SAMPLE_DATA/Bands Data.jmp", Invisible );

// Create a window with both tables shown
New Window( "Both Tables",
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		a = dt1 << New Data Box(), // Returns DataBrowserBox
		b = dt2 << New Data Box()  // Returns DataBrowserBox
	)
);

// Close the side panels for both tables
a << close side panels();
b << close side panels();

The resulting window:

Capture.PNG

Justin
matt7109

Contributor

Joined:

Jun 9, 2017

Perfect!! Thanks!

matt7109

Contributor

Joined:

Jun 9, 2017

I like this solution a lot as it's all in one window. However, is there any way to make this sort of display in a JMP table window where the user can save the file, rather than in a window? 

 

 

Justin_Chilton

Joined:

Aug 27, 2015

Solution

Hi @matt7109,

The menu and toolbars you see are limited to one per window. You will need to create your own custom behaviors for actions (like save) that would typically be done using the menu or toolbars. 

The below script creates a red triangle menu that will save the data table within the Outline Box. Notice that I turned on the "Data Table List" in the toolbar so that you can see the current data table. With this method, you can still use the menus (Tables, DOE, Analyze, Graph) that will perform actions on the current data table shown in the data table list.

 

Names Default To Here( 1 );
// open the tables as private
dt1 = Open( "$SAMPLE_DATA\Big Class.jmp", private );
dt2 = Open( "$SAMPLE_DATA\Bands Data.jmp", private );

// Create a function to create each data table to reduce code redundancy
getDataTableOutlineBox = Function( {dt},
	Eval(
		Eval Expr(
			Outline Box( dt << Get Name, // title of the tab
				dt << New Data Box(), //DataBrowserBox
				// Add scripts to the Red Triangle menu for the Outline Box
				<<Set Menu Script(
					{
						"Save As", // Name of the menu item script
						
						// get path to save the data table
						savePath = Pick File(
							"Save JMP Data Table",
							"",
							{"JMP Files|jmp", "All Files|*"},
							1,
							1,
							Expr( dt << get name ) || ".jmp" // evaluate the name of the table when the menu script is added
						);
						// If the user selected a path, save the table at that path
						If( savePath != "",
							Expr( dt ) << save( savePath )
						); 
					
					}
				)
			)
		)
	)
);

// (optional) Turn on the Data Table list for reports so that you can see what the current data table is
Set Toolbar Visibility( "Data Table List", Report, true );

// Create a window with both tables shown
New Window( "Both Tables",
	Suppress AutoHide( 1 ), // Suppress the auto hide so that the toolbars appear
	<<OnClose(
		Try( Close( dt1, NoSave ) );
		Try( Close( dt2, NoSave ) );
	),
	H Splitter Box(
		size( 1200, 800 ),
		getDataTableOutlineBox( dt1 ),
		getDataTableOutlineBox( dt2 ),

	)
);

Below is a screenshot of the window after clicking on the Red Triangle Menu. 

2017-07-13_12-44-55.png

 

Justin
matt7109

Contributor

Joined:

Jun 9, 2017

This is perfect!! Thank you so much !