<?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: Need help with populating Col List Box in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479083#M72333</link>
    <description>&lt;P&gt;Since I use this Col List Box to cast columns in many different roles using buttons and another Col List Boxes (as in any platform), I need to re-create MANY col list boxes, with different settings etc. So I wrote an universal function for that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;refreshDisplayBox = Function({dt, box, expr},
	parent = box &amp;lt;&amp;lt; Parent;
	box &amp;lt;&amp;lt; Delete Box;
	parent &amp;lt;&amp;lt; Append(box = expr);
	Return (box);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;dt is needed here in case if it is used in expr to re-create the Display Box. It gets passed into the function regardless of what handle for that table you're using outside of the function. Just need to remember to write all the expressions with "dt" for that.&lt;/P&gt;&lt;P&gt;Then the script is going to look like this:&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 );

refreshDisplayBox = Function({dt, box, expr},
	parent = box &amp;lt;&amp;lt; Parent;
	box &amp;lt;&amp;lt; Delete Box;
	parent &amp;lt;&amp;lt; Append(box = expr);
	Return (box);
);
colListExpr = Expr(Col List Box(dt/*use generic dt*/, all));

open = Expr(dtEXT/*different table name*/ = Open( "$SAMPLE_DATA/Big Class.jmp" ); lb = refreshDisplayBox(dtEXT/*pass it into the function*/, lb, colListExpr));

gui = Expr(V List Box(btn = Button Box ("OPEN", open), pb = Panel Box("Column List", lb = Col List Box())));

New Window( "Col List Box Example",
	gui;
);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Let me know if this is a valid approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 07:37:07 GMT</pubDate>
    <dc:creator>miguello</dc:creator>
    <dc:date>2022-04-14T07:37:07Z</dc:date>
    <item>
      <title>Need help with populating Col List Box</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479062#M72331</link>
      <description>&lt;P&gt;Part of my App's GUI has a button that opens a table, and a Col List Box that I need to populate with columns from that table.&lt;/P&gt;&lt;P&gt;If I open the table first and then create Col Lis Box as in this modified Example from Scripting Index, everything works fine:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Col List Box Example",
lb = Col List Box()
);

lb &amp;lt;&amp;lt; Append (dt &amp;lt;&amp;lt; Get Column Names);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, if I create the window with GUI that has button to open the table, i.e. I create Col List Box first and then open the table, it stops working. This is a simplified version of real code but it has the same problem - Col List Box does not populate with column names.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
open = Expr(dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); lb &amp;lt;&amp;lt; Append (dt &amp;lt;&amp;lt; Get Column Names););
gui = Expr(V List Box(btn = Button Box ("OPEN", open), lb = Col List Box()));

New Window( "Col List Box Example",
	gui;
);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What am I doing wrong? How can I make it work?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:56:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479062#M72331</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2023-06-09T16:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with populating Col List Box</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479082#M72332</link>
      <description>&lt;P&gt;Ok, it looks like when ColListBox is created it is connected to the current data table. And you can only add columns from that DT.&lt;/P&gt;&lt;P&gt;So, since I need to show columns from different DTs in my GUI in the same COlLIstBox, I need to redefine it each time. Delete the old one and create a new one instead.&lt;/P&gt;&lt;P&gt;This seems to be working, please let me know if there is a better solution:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
open = Expr(dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); refreshColList;);
refreshColList = Expr(
	(pb &amp;lt;&amp;lt; Child) &amp;lt;&amp;lt; Delete Box;
	pb &amp;lt;&amp;lt; Append(lb = Col List Box(dt, all));
);
gui = Expr(V List Box(btn = Button Box ("OPEN", open), pb = Panel Box("Column List", lb = Col List Box())));

New Window( "Col List Box Example",
	gui;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 07:20:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479082#M72332</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2022-04-14T07:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with populating Col List Box</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479083#M72333</link>
      <description>&lt;P&gt;Since I use this Col List Box to cast columns in many different roles using buttons and another Col List Boxes (as in any platform), I need to re-create MANY col list boxes, with different settings etc. So I wrote an universal function for that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;refreshDisplayBox = Function({dt, box, expr},
	parent = box &amp;lt;&amp;lt; Parent;
	box &amp;lt;&amp;lt; Delete Box;
	parent &amp;lt;&amp;lt; Append(box = expr);
	Return (box);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;dt is needed here in case if it is used in expr to re-create the Display Box. It gets passed into the function regardless of what handle for that table you're using outside of the function. Just need to remember to write all the expressions with "dt" for that.&lt;/P&gt;&lt;P&gt;Then the script is going to look like this:&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 );

refreshDisplayBox = Function({dt, box, expr},
	parent = box &amp;lt;&amp;lt; Parent;
	box &amp;lt;&amp;lt; Delete Box;
	parent &amp;lt;&amp;lt; Append(box = expr);
	Return (box);
);
colListExpr = Expr(Col List Box(dt/*use generic dt*/, all));

open = Expr(dtEXT/*different table name*/ = Open( "$SAMPLE_DATA/Big Class.jmp" ); lb = refreshDisplayBox(dtEXT/*pass it into the function*/, lb, colListExpr));

gui = Expr(V List Box(btn = Button Box ("OPEN", open), pb = Panel Box("Column List", lb = Col List Box())));

New Window( "Col List Box Example",
	gui;
);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Let me know if this is a valid approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 07:37:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479083#M72333</guid>
      <dc:creator>miguello</dc:creator>
      <dc:date>2022-04-14T07:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with populating Col List Box</title>
      <link>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479554#M72382</link>
      <description>&lt;P&gt;Yes this is a valid way to approach this. I re-wrote this slightly to show another way to get to the same result:&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 );

LoadTable = function( {dtname}, {dt, lbnew},
	dt = open("$SAMPLE_DATA/" || dtname);
	lbnew = Col List Box(dt, all);
	window:lb &amp;lt;&amp;lt; Delete Box;
	window:pb &amp;lt;&amp;lt; Append( window:lb = lbnew );
	win &amp;lt;&amp;lt; Bring Window to Front;
);

win = New Window( "Col List Box Example",
	vlb = V List Box(
		H List Box(
			window:clb = List Box( { "Big Class.jmp", "Iris.jmp" } ),
			window:btn = Button Box ("OPEN", LoadTable((window:clb &amp;lt;&amp;lt; Get Selected)[1]) )
		),
		window:pb = Panel Box("Column List", 
			window:lb = Col List Box()
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Apr 2022 14:39:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Need-help-with-populating-Col-List-Box/m-p/479554#M72382</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2022-04-15T14:39:19Z</dc:date>
    </item>
  </channel>
</rss>

