cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
kuannygoh
Level I

using loop to display a tab box inside a tab box

Hi guys , I am trying to display a tab box inside a tab box using loop 

Below is my code , however it does not allowa me to use array , only variablee allowed . 

 

New Window( "Result", display = Tab Box() );
For( j = 1, j <= N Items( stepname ), j++,
	step = Substitute( Char( stepname[j] ), "DataTable(\!"Specname=", "" );
	display << Add(
		step,
		main[j] = Tab Box(
			
		)
	);
1 REPLY 1
gzmorgan0
Super User (Alumni)

Re: using loop to display a tab box inside a tab box

From your brief description, it seems you are trying to display different specs for different steps. The first script shows a method that uses arrays to make a tabbed display of tabs.

Names Default to Here(1);
steps= {"A", "B", "C", "D"};
step_aa = Associative Array(steps);
step_aa["A"] = {"1101", "1102", "1103", "1104"};
step_aa["B"] = {"2101", "2102", "2207", "2068", "270X"};
step_aa["C"] = {"37Z0", "3027", "3133"};
step_aa["D"] = {"4001", "4005", "4517"};

main={};
New Window( "Result", display = Tab Box() );
For( j = 1, j <= N Items( stepname ), j++,
	display << Add(
		steps[j], PanelBox("",
		tb = Tab Box();
	));
	tb << Set OverFlow Enabled(0);
	insert into(main,tb);
);
For( j = 1, j <= N Items( stepname ), j++,
		for(k=1, k<=nitems(step_aa[steps[j]]), k++,	
		  main[j] << Add (EvalInsert("Data Table(\!"Specname=^step_aa[steps[j]][k]^\!")"))
		  
		); // add for k   
		main[j] << set selected(1); //select the first tab
);
display << set selected(1);

image.png

 

 

However, I think a better option is to use a Tree with TreeNodes. Below is an example and the resulting display.

Names Default to Here(1);
steps= {"A", "B", "C", "D"};
step_aa = Associative Array(steps);
step_aa["A"] = {"1101", "1102", "1103", "1104"};
step_aa["B"] = {"2101", "2102", "2207", "2068", "270X"};
step_aa["C"] = {"37Z0", "3027", "3133"};
step_aa["D"] = {"4001", "4005", "4517"};


roots = {};
For( j = 1, j <= N Items( steps ), j++,
   root = TreeNode(stepname[j]);
   insert into(roots, root);
);
For( j = 1, j <= N Items( steps ), j++,
   For(k =1, k<=nitems(step_aa[steps[j]]), k++,
      c = Tree Node( step_aa[steps[j]][k] );
      roots[j] << Append(c);
   );
);
New Window( "TreeBox Tests",
	HListBox(
	   tree = Tree Box( roots, Size( 300, 200 ) ),
	   tb = TextBox()
	)
);
tree << Set Node Select Script(
	Function( {thistree, thisnode},
		If( !Is Empty( thisnode ),
		    txt = thisnode << get label;
			tb << set text ( EvalInsert("Data Table(\!"Specname=^txt^\!")") )
		)
	)
);

image.png