cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mikedriscoll
Level VI

Change color and underline contents of a string col box or table box.

Hi, I posted a similar version of the code below last week, and now I'm trying to update the values in the string col box() / table box() to be blue and underlined so they appear to be hyperlinks. The table box << text color() command was not working for me, but the string col box << text color() works. Is there a way to do this so the header of the column, "names" in the example below, does not change color?  Is there a way to set the values to be underlined? 

Thanks

Mike

 

 

Names Default To Here( 1 );

//dummy data table
dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

// create a list of columns. In the example table, the first 4 columns are categorical index columns, so we'll use 20 columns starting at column 5 (4 + i)
colList = {};
for( i = 1, i<=20, i++,
	colList[i] = as column(dt, 4 + i) << get name();
);

// new window, table box with selectable rows
nw = New Window( "Example",
	vlb = vlistbox(
		mainOlb = Outline Box( "Table", // used for referencing scrolling back to top
			tb = Table Box(
				scb = String Col Box( "names", colList ),  // scb will be used later to color in blue to indicate it is a pseudo-hyperlink
				<<set selectable rows() // making the rows selectable is how we can capture that row selection has changed, and the <<set row change function() will scroll to the corresponding distribution
			)
		)
	);
);

scb << text color(rgb color(0,0,255)); // any way to set it so only the values are blue, and not the header, 'names' in this case? 
scb << set underline(1); // not a real command

//append some distributions in their own context boxes, but keep a reference variable for the conext box cb[i].
cb = {};
for( i = 1, i <= 20, i++,
	vlb <<  append(
		cb[i] = contextbox(
			distribution(column(4 + i)) // put the i'th distribution in context box[i]
		)
	);
	vlb<<append(buttonbox("Back", nw << scroll window(mainOlb))); //back to top
);

//set what happens when a row is selected. itemNum is a matrix of all selected rows.
//	The 'this' variable here explained:  When a row is selected, the set row change function(x) is called. The input variable x is copy of the table box. So 'this' refers to a copy of the table box. 
//  'this << get selected rows()' just returns a matrix of the selected rows. Since we can't set max # of rows selected, we just use the first.
tb << set row change function(
	Function( {this},
		Print( this << get selected rows );
		itemNum = this << get selected rows();
		if(nrows(itemNum) > 0,
			nw << scroll window(cb[itemNum[1]]);
		);
	)
);

JMP standard version 16.2.0

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Change color and underline contents of a string col box or table box.

You could maybe use Col Box instead of String Col Box and use button boxes in col box

Names Default To Here( 1 );

//dummy data table
dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

// create a list of columns. In the example table, the first 4 columns are categorical index columns, so we'll use 20 columns starting at column 5 (4 + i)
colList = {};
for( i = 1, i<=20, i++,
	colList[i] = as column(dt, 4 + i) << get name();
);

// new window, table box with selectable rows
nw = New Window( "Example",
	vlb = vlistbox(
		mainOlb = Outline Box( "Table", // used for referencing scrolling back to top
			tb = Table Box(
				scb = Col Box( "names", {}),  // scb will be used later to color in blue to indicate it is a pseudo-hyperlink
			)
		)
	);
);

For Each({col}, colList,
	scb << Append(Button Box(col, << Set Function(function({this},
			nw << scroll window(cb[Contains(colList, this << Get Button Name)]);
		)), << Underline Style(1);
	));
);

//append some distributions in their own context boxes, but keep a reference variable for the conext box cb[i].
cb = {};
for( i = 1, i <= 20, i++,
	vlb <<  append(
		cb[i] = contextbox(
			distribution(column(4 + i)) // put the i'th distribution in context box[i]
		)
	);
	vlb<<append(buttonbox("Back", nw << scroll window(mainOlb))); //back to top
);
-Jarmo

View solution in original post

pmroz
Super User

Re: Change color and underline contents of a string col box or table box.

Justin Chilton and I gave a talk that included col boxes at the Discovery 2018 Summit.

Supercharge Your User Interfaces in JSL ( US 2018 113 ) 

 

View solution in original post

9 REPLIES 9
jthi
Super User

Re: Change color and underline contents of a string col box or table box.

You could maybe use Col Box instead of String Col Box and use button boxes in col box

Names Default To Here( 1 );

//dummy data table
dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

// create a list of columns. In the example table, the first 4 columns are categorical index columns, so we'll use 20 columns starting at column 5 (4 + i)
colList = {};
for( i = 1, i<=20, i++,
	colList[i] = as column(dt, 4 + i) << get name();
);

// new window, table box with selectable rows
nw = New Window( "Example",
	vlb = vlistbox(
		mainOlb = Outline Box( "Table", // used for referencing scrolling back to top
			tb = Table Box(
				scb = Col Box( "names", {}),  // scb will be used later to color in blue to indicate it is a pseudo-hyperlink
			)
		)
	);
);

For Each({col}, colList,
	scb << Append(Button Box(col, << Set Function(function({this},
			nw << scroll window(cb[Contains(colList, this << Get Button Name)]);
		)), << Underline Style(1);
	));
);

//append some distributions in their own context boxes, but keep a reference variable for the conext box cb[i].
cb = {};
for( i = 1, i <= 20, i++,
	vlb <<  append(
		cb[i] = contextbox(
			distribution(column(4 + i)) // put the i'th distribution in context box[i]
		)
	);
	vlb<<append(buttonbox("Back", nw << scroll window(mainOlb))); //back to top
);
-Jarmo
mikedriscoll
Level VI

Re: Change color and underline contents of a string col box or table box.

Thanks Jarmo. It definitely looks better, though there is the downside of not being able to right click and 'make into data table', but I don't think that feature is that important. 

 

I had typed these two questions here, but I just answered them for myself...  What code is changing the text to blue?  And why do the button boxes appear as text only and not the usual buttons we see like the 'back' to top examples here?  The answer is your << Underline Style(1); does both of these things. Seems it is an alternate display of the button box. Thanks for sharing, I didn't know about that. 

jthi
Super User

Re: Change color and underline contents of a string col box or table box.

There are also some other downsides on using col box, for example more difficult to get values from, sometimes you can crash JMP when building Col Box... but I don't know of any simple means of changing String Col Box title color besides <<Text Color which will change color of all elements.

-Jarmo
mikedriscoll
Level VI

Re: Change color and underline contents of a string col box or table box.

Can you elaborate further on the part about JMP crashing?  Is it predictable, or does it happen with a large number of items in a col box()?  I'd probably want to avoid this in many cases, as it is likely to be used in scripts where any number of parameters may be plotted. Anywhere from a few plots to a thousand or so.

mikedriscoll
Level VI

Re: Change color and underline contents of a string col box or table box.

Hi @jthi , sorry to bother you, but I was hoping you or maybe someone from the JMP team could elaborate further on the part about JMP crashing when building a col box. Any tips on how to avoid that sort of behavior? 

jthi
Super User

Re: Change color and underline contents of a string col box or table box.

You should be able to avoid the crashes by building Col Box "correctly". If I remember correctly << append has worked for me, but you cannot use << Set. I have contacted support about that sometime ago. Issue is supposed to be fixed on JMP17.

 

My example I provided them with was this (THIS WILL CRASH JMP16):

Names Default To Here(1);
stop(); // THIS WILL CRASH JMP nw = New WindoW("", Table Box( cb = Col Box("icons", Icon Box("Excluded"), Icon Box("Excluded"), ) ) ); cb << Set({"a", "b"});

So if I were to use Col Box and wanted to replace value, I would always just rebuild it.

 

-Jarmo
mikedriscoll
Level VI

Re: Change color and underline contents of a string col box or table box.

Thanks very much Jarmo.  I appreciate the help and insight on the behavior.

pmroz
Super User

Re: Change color and underline contents of a string col box or table box.

Justin Chilton and I gave a talk that included col boxes at the Discovery 2018 Summit.

Supercharge Your User Interfaces in JSL ( US 2018 113 ) 

 

mikedriscoll
Level VI

Re: Change color and underline contents of a string col box or table box.

Thank you Peter. That was a great presentation, and it was very helpful.