cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Add special display box element for Data Table List similar to Toolbar

Currently it is quite a hassle to script similar functionality as is already found from the toolbar. Add new element which could be used for this purpose, it should also auto-update. This is fairly common type of element I add to my user-interfaces to let user change current data table, bring it to front or to just quickly see what is current data table.

 

5 Comments
SamGardner
Staff
Status changed to: Needs Info

@jthi when you say toolbar do you mean the JMP toolbar that can be displayed at the top of every report window?

SamGardner_0-1658407081378.png

It is possible to customize the JMP Toolbars, described here:  https://www.jmp.com/support/help/en/16.2/index.shtml#page/jmp/customize-toolbars.shtml#.  Does that meet your needs?

If not, can you share a mock-up, script, or wireframe of what you would like to be able to do?  

 

jthi
Super User

Using Toolbar isn't enough for my purposes.

 

I did write a script which "mostly" does what I want but writing it is unnecessarily complicated (in my opinion). I will share it here in September when I get back to work.

jthi
Super User

The code is bit messy as I just "borrowed" from one of my tools (most likely should write this into a class). But basically:

  1. I have Combo Box with initial data table list and Current Data Table set as the current selection
    1. I have set function to Combo Box which will update Filter Col Selector based on value change (change data table). It does not change Current Data Table or change when Current Data Table changes.
  2. I have Filter Col Selector which is supposed to use same table as can be seen in Combo Box
  3. I use subscribe to data table list to keep track of new tables, renames and closing of data tables. And the functions try to manage all these changes and how they affect combo box
  4. When the window is closed I remove my subscription to data table list

 

Code example:

 

View more...
Names Default To Here(1);

// To initialize Combo Box
init_dt_list = Get Data Table List() << Get Name;
If(N Items(init_dt_list) == 0,
	Throw("No tables open");
);

dt = Current Data Table();
init_dt_idx = Contains(init_dt_list, dt << get name());

nw = New Window("test",
	window:dt = dt;
	H List Box(
		Lineup Box(N Col(2),
			window:cb_table = Combo Box(init_dt_list, << Set(init_dt_idx), << Set Function(function({this},
				// must be done this way to recover from no tables open?
				If((this << get selected) != "(SELECT TABLE)", 
					all_items = this << get items;
					If(Contains(all_items, "(SELECT TABLE)"),
						this << Remove Item(Contains(all_items, "(SELECT TABLE)"));
					);
					window:dt = Datatable((this << get selected));
// redo filter col selector (window:ob_column_selection << child) << Delete Box(); Eval(EvalExpr(nw:ob_column_selection << Append(V List Box( window:fcs = Filter Col Selector(Datatable(Expr(Datatable(window:dt))), << Set N Lines(5)), window:fcs[IfBox(1)] << Set(1); )))); ); )), << Set Tip("Data Table") ), window:btn_table = Button Box("", << Set Function(function({this}, window:dt = Datatable(window:cb_table << Get Selected); window:dt << Bring Window To Front; )), << Set Icon("ActivateDataTable"), << Set Tip("View Data Table") ) ), window:ob_column_selection = Outline Box("Column Selector", V List Box( // Necessary evil for easier filter col selector updating window:fcs = Filter Col Selector(Datatable(dt), << Set N Lines(5)), window:fcs[IfBox(1)] << Set(1) ) ) ) ); // Functions for different changes in data table list Eval(EvalExpr(f_open = function({dtab}, cur_dts = Reverse(Get Data Table List() << Get Name); cur_dt = Expr(nw:cb_table) << Get Selected; If(cur_dt == "(no tables)", nw:dt = Datatable(dtab); ); Expr(nw:cb_table) << Set Items(cur_dts); Expr(nw:cb_table) << Set(Contains(cur_dts, cur_dt)); If(N items(cur_dts) == 1, // add (SELECT TABLE) temp item to recover from empty table situation Expr(nw:cb_table) << Append Item("(SELECT TABLE)"); Expr(nw:cb_table) << Set(2, Run Script(0)); ); ))); Eval(EvalExpr(f_rename = function({dtab, b}, cur_dts = Reverse(Get Data Table List() << Get Name); cur_dt = Expr(nw:cb_table) << Get Selected; Substitute Into(cur_dts, b, (dtab << get name)); If(cur_dt == b, cur_dt = dtab << get name; ); Expr(nw:cb_table) << Set Items(cur_dts); Expr(nw:cb_table) << Set(Contains(cur_dts, cur_dt)); ))); Eval(EvalExpr(f_close = function({dtab}, cur_dts = Reverse(Get Data Table List() << Get Name); Remove From(cur_dts, Contains(cur_dts, dtab << get name)); cur_dt = Expr(nw:cb_table) << Get Selected; If(cur_dt == dtab << get name(), cur_dt = Current Data Table() << get name; ); nw:cb_table << Set Items(cur_dts); Expr(nw:cb_table) << Set(Contains(cur_dts, cur_dt)); If(N Items(cur_dts) == 0, nw:cb_table << Set Items({"(no tables)"}); ); ))); // Subscription to data table list aSub = Subscribe to Data Table List(, OnOpen(f_open)); Eval(EvalExpr(Subscribe to Data Table List(Expr(aSub), On Rename(f_rename)))); Eval(EvalExpr(Subscribe to Data Table List(Expr(aSub), OnClose(f_close)))); // To remove subscription Eval(EvalExpr(nw << On Close( Try(Unsubscribe to Data Table List(Expr(aSub), "ALL")); )));

What I would like to have is some simpler element to manage this same operation. I could write it as a class myself but I think this could be useful for other JSL Scripters also who create user interfaces. Simple way to manage this is to just use buttons instead of data table subscription (refresh table list), but this could be much cleaner way.

 

 

SamGardner
Staff

That script gives me a better idea of what you want, but what is still unclear is what you mean by "similar functionality as is already found from the toolbar".  Are you wanting a new display box that shows all open tables, that can be used in any scripted report window?  Is the selection of columns in the table important?  It would help if you could describe an example of where this could be used.  

jthi
Super User

By "similar functionality as is already found from the toolbar" I mean a Combo Box which would have its list updated when data table is opened, renamed or closed.

The functionality would be a bit different than toolbar because it shouldn't change table when current data table changes but trigger in similar manner as << Set Function does for Combo Box.

 

Use case:

  • I have a tool which can perform complicated analyses on different kinds of data tables but the startup of that tool takes quite a long time
  • In "normal" case you would just run the tool on Current Data Table(). But if you want to run it on multiple tables it would be beneficial to have easy to use table changer due to the long startup.

For exampleData Table Tools Add-in is one add-in which has listbox and refresh table list button which could be replaced with this element (if it would fit the UI).