<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: color TableBox rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381743#M63227</link>
    <description>&lt;P&gt;I had one script where I wanted to do something similar (in the end I gave up with it and went with different approach for the application, because it got a bit too complicated for my taste for no reason).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified it a bit and this will get you the basic window:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("a",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 2, 3])
	),
	New Column("b",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	New Column("c",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	invisible
);

dt &amp;lt;&amp;lt; Select Where(:a &amp;gt; 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Red");	
);
dt &amp;lt;&amp;lt; Clear Select;

dt &amp;lt;&amp;lt; Select Where(:a == 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Green");	
);
dt &amp;lt;&amp;lt; Clear Select;
rep = dt &amp;lt;&amp;lt; get as report;
Close(dt, no save);
nw = New Window("Example", 
	hlb = h list box()
);
rep &amp;lt;&amp;lt; append(Col Box("Open Graph", Button Box("ok"),Button Box("ok"),Button Box("ok")));
hlb &amp;lt;&amp;lt; append(rep);
tb = (hlb &amp;lt;&amp;lt; XPath("//TableBox"))[1];
tb &amp;lt;&amp;lt; Set Scrollable(5,5);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Idea was to color the datatable, get the datatable as report, add buttons to that report and finally append that to new window (and resize).&lt;/P&gt;</description>
    <pubDate>Sun, 02 May 2021 07:34:39 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2021-05-02T07:34:39Z</dc:date>
    <item>
      <title>color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/380338#M63071</link>
      <description>&lt;P&gt;I have a table box that has text but also buttons and I want to color it it more then 1 color&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col1 = {1, 2, 3};
col2 = {1, 2, 3};
col3 = {1, 2, 3};
myPlatform = New Window( "test",
	tb = Table Box(
		Number Col Box( "a", col1 ),
		Number Col Box( "b", col2 ),
		Number Col Box( "c", col3 ),
		bb = Col Box( "Open Graph" )
	)
);


bblist = {};
For( i = 1, i &amp;lt;= 3, i++,
	bb_expr = Eval Insert( "\[bblist[i] = buttonbox("ok")]\" );
	Eval( Parse( bb_expr ) );
	bb &amp;lt;&amp;lt; append( bblist[i] );
);

tb &amp;lt;&amp;lt; Set Selectable Rows(1);
dt = tb &amp;lt;&amp;lt; Make into Data Table( invisible );
rs = dt &amp;lt;&amp;lt; Get Rows Where( :a &amp;gt; 1 );
tb &amp;lt;&amp;lt; Set Selected Rows( rs );
tb &amp;lt;&amp;lt; Set Selected Row Color( "red" );
rs = dt &amp;lt;&amp;lt; Get Rows Where( :a == 1 );
tb &amp;lt;&amp;lt; Set Selected Rows( rs );
tb &amp;lt;&amp;lt; Set Selected Row Color( "green" );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The problem is that if I remove the last 2 lines, it colors the last 2 lines in red, but if I do run the last 2 lines, it removes the red color and colors in green the top line instead of leaving the red color as well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before running last 2 lines:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="itzikd_0-1619595029444.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32382i0ED112556D68FF41/image-size/medium?v=v2&amp;amp;px=400" role="button" title="itzikd_0-1619595029444.png" alt="itzikd_0-1619595029444.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after running last 2 lines&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="itzikd_1-1619595059193.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32383iF6EA85EA2EB8138A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="itzikd_1-1619595059193.png" alt="itzikd_1-1619595059193.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to color the table box in more then 1 color? (I want it to have both red and green colors)&lt;/P&gt;&lt;P&gt;I tried working with journal as well, but then I'm not sure how to add the buttons.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:45:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/380338#M63071</guid>
      <dc:creator>itzikd</dc:creator>
      <dc:date>2023-06-09T19:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381740#M63226</link>
      <description>even if you can't do it with table box, is there another way to do this? the problem is that i need to add the buttons to it as well somehow</description>
      <pubDate>Sun, 02 May 2021 05:36:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381740#M63226</guid>
      <dc:creator>itzikd</dc:creator>
      <dc:date>2021-05-02T05:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381743#M63227</link>
      <description>&lt;P&gt;I had one script where I wanted to do something similar (in the end I gave up with it and went with different approach for the application, because it got a bit too complicated for my taste for no reason).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified it a bit and this will get you the basic window:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("a",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 2, 3])
	),
	New Column("b",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	New Column("c",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	invisible
);

dt &amp;lt;&amp;lt; Select Where(:a &amp;gt; 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Red");	
);
dt &amp;lt;&amp;lt; Clear Select;

dt &amp;lt;&amp;lt; Select Where(:a == 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Green");	
);
dt &amp;lt;&amp;lt; Clear Select;
rep = dt &amp;lt;&amp;lt; get as report;
Close(dt, no save);
nw = New Window("Example", 
	hlb = h list box()
);
rep &amp;lt;&amp;lt; append(Col Box("Open Graph", Button Box("ok"),Button Box("ok"),Button Box("ok")));
hlb &amp;lt;&amp;lt; append(rep);
tb = (hlb &amp;lt;&amp;lt; XPath("//TableBox"))[1];
tb &amp;lt;&amp;lt; Set Scrollable(5,5);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Idea was to color the datatable, get the datatable as report, add buttons to that report and finally append that to new window (and resize).&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 07:34:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381743#M63227</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-02T07:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381750#M63228</link>
      <description>&lt;P&gt;thanks! this helps a lot!&lt;/P&gt;&lt;P&gt;but what if I want to create buttons dynamically&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bblist = {};
For( i = 1, i &amp;lt;= 3, i++,
	bb_expr = Eval Insert( "\[bblist[i] = buttonbox("test")]\" );
	Eval( Parse( bb_expr ) );
	bb &amp;lt;&amp;lt; append( bblist[i] );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;when I try to do&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rep &amp;lt;&amp;lt; append(Col Box("Open Graph", bb));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it doesn't work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any suggestion?&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 13:53:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381750#M63228</guid>
      <dc:creator>itzikd</dc:creator>
      <dc:date>2021-05-02T13:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381752#M63230</link>
      <description>&lt;P&gt;Not completely sure what is wrong there (could be that Col Box() wouldn't take list as argument as it seems to need comma separated display boxes). But this could be one way to do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bblist = Expr(col box("Open Graph"));
For( i = 1, i &amp;lt;= 3, i++,
	Insert Into(bblist, buttonbox("test"||char(i)));
);

rep &amp;lt;&amp;lt; append(bblist);
hlb &amp;lt;&amp;lt; append(rep);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 May 2021 14:46:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381752#M63230</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-02T14:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381854#M63244</link>
      <description>&lt;P&gt;thanks! this helps a lot&lt;/P&gt;&lt;P&gt;I have 1 last question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using this code, I'm trying to create for each button a different value in the function.&lt;/P&gt;&lt;P&gt;so in this example if I click button 1 it should print 1, if I click 2 it should print 2 and so on..&lt;/P&gt;&lt;P&gt;but for some reason the value doesn't "stick" and any button I click it says 4.(4 is the number of i after the loop ends)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = New Table("Untitled",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("a",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([1, 2, 3])
	),
	New Column("b",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	New Column("c",
		Numeric,
		"Continuous",
		Format("Best", 12),
		Set Values([2, 2, 3])
	),
	invisible
);

newFunc = function({i},
	print(i);
);

dt &amp;lt;&amp;lt; Select Where(:a &amp;gt; 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Red");	
);
dt &amp;lt;&amp;lt; Clear Select;

dt &amp;lt;&amp;lt; Select Where(:a == 1);
For(i = 1, i &amp;lt;= N Cols(dt), i++,
	Column(dt, i) &amp;lt;&amp;lt; Color Cells("Green");	
);
dt &amp;lt;&amp;lt; Clear Select;
rep = dt &amp;lt;&amp;lt; get as report;
Close(dt, no save);
nw = New Window("Example", 
	hlb = h list box()
);
bblist = Expr(col box("Open Graph"));
For( i = 1, i &amp;lt;= 3, i++,
	Insert Into(bblist, buttonbox("test"||char(i),newFunc(i)));
);

rep &amp;lt;&amp;lt; append(bblist);
hlb &amp;lt;&amp;lt; append(rep);
tb = (hlb &amp;lt;&amp;lt; XPath("//TableBox"))[1];
tb &amp;lt;&amp;lt; Set Scrollable(5,5);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is there a way to fix this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 07:15:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381854#M63244</guid>
      <dc:creator>itzikd</dc:creator>
      <dc:date>2021-05-03T07:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: color TableBox rows</title>
      <link>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381857#M63245</link>
      <description>&lt;P&gt;You can easily check what is the issue by using Set Script on one of the buttons from the window that opens:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1620026941571.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32540i711A4EE6EC5831B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1620026941571.png" alt="jthi_0-1620026941571.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i is the argument when it should be the number. You could go with Eval(Parse()) way to fix it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= 3, i++,
	Insert Into(bblist, Eval(Parse("buttonbox(\!"test"||char(i)||"\!",newFunc("||char(i)||"))")));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or Eval(Eval Expr()):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= 3, i++,
	Eval(EvalExpr(Insert Into(bblist, buttonbox("test"||char(expr(i)),newFunc(expr(i))))));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You want the Set Script to look like this (at least in this case):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1620027253658.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/32541iF393DCFE8CA268D2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1620027253658.png" alt="jthi_1-1620027253658.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Best" way to do this will most likely be highly application dependant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 07:34:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/color-TableBox-rows/m-p/381857#M63245</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-05-03T07:34:39Z</dc:date>
    </item>
  </channel>
</rss>

