<?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: How to Dynamically List Column names of Selected Data Table? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415494#M66452</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use code like the following to do this. Try running this code when you have a few data tables open.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

//get a list of window names
windows = Window() &amp;lt;&amp;lt; get window title;

//remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i &amp;gt; 0, i--,
	If( (Window( windows[i] ) &amp;lt;&amp;lt; Window Class Name) != "DataTable",
		Remove From( windows, i )
	)
);

//make a dialog window
nw = New Window( "Sample",
	vlb1 = V List Box(
		lb1 = List Box(
			windows,	//populate the listbox with data table names
			
			//here is the script that runs each time someone clicks in the top box
			//delete the current column list box, if it exists
			Try( lb2 &amp;lt;&amp;lt; delete );				
			
			//append a new col list box, with all columns of the data table selected in the listbox
			vlb1 &amp;lt;&amp;lt; append( lb2 = Col List Box( Data Table( (lb1 &amp;lt;&amp;lt; get selected)[1] ), all ) );		
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_0-1630705687855.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35533i5823804F72D3828A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_0-1630705687855.png" alt="brady_brady_0-1630705687855.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_1-1630705698471.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35534i0F93B5B4BEEC4D5E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_1-1630705698471.png" alt="brady_brady_1-1630705698471.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Sep 2021 21:48:30 GMT</pubDate>
    <dc:creator>brady_brady</dc:creator>
    <dc:date>2021-09-03T21:48:30Z</dc:date>
    <item>
      <title>How to Dynamically List Column names of Selected Data Table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415321#M66444</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I'm tring to creat a windows like Tables-Join, which the second outline box could dynamically list the column names of selected data table in the upleft corner list box.&lt;/P&gt;&lt;P&gt;Thanks in advanced.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:55:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415321#M66444</guid>
      <dc:creator>蘇71</dc:creator>
      <dc:date>2023-06-09T19:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically List Column names of Selected Data Table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415494#M66452</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use code like the following to do this. Try running this code when you have a few data tables open.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

//get a list of window names
windows = Window() &amp;lt;&amp;lt; get window title;

//remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i &amp;gt; 0, i--,
	If( (Window( windows[i] ) &amp;lt;&amp;lt; Window Class Name) != "DataTable",
		Remove From( windows, i )
	)
);

//make a dialog window
nw = New Window( "Sample",
	vlb1 = V List Box(
		lb1 = List Box(
			windows,	//populate the listbox with data table names
			
			//here is the script that runs each time someone clicks in the top box
			//delete the current column list box, if it exists
			Try( lb2 &amp;lt;&amp;lt; delete );				
			
			//append a new col list box, with all columns of the data table selected in the listbox
			vlb1 &amp;lt;&amp;lt; append( lb2 = Col List Box( Data Table( (lb1 &amp;lt;&amp;lt; get selected)[1] ), all ) );		
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_0-1630705687855.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35533i5823804F72D3828A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_0-1630705687855.png" alt="brady_brady_0-1630705687855.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_1-1630705698471.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35534i0F93B5B4BEEC4D5E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_1-1630705698471.png" alt="brady_brady_1-1630705698471.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 21:48:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415494#M66452</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-09-03T21:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically List Column names of Selected Data Table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415518#M66457</link>
      <description>&lt;P&gt;Thank you for your reply. I replace 'col list box' with 'filter col selector', it doesn't work as expected, a red triangle left every time I select a table, the column list doesn't update accordingly.&lt;/P&gt;&lt;P&gt;how does it work through by using 'filter col selector' ?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

//get a list of window names
windows = Get Data Table List();

/*remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i &amp;gt; 0, i--,
	If( (Window( windows[i] ) &amp;lt;&amp;lt; Window Class Name) != "DataTable",
		Remove From( windows, i )
	)
);
*/
//make a dialog window
nw = New Window( "Sample",
	vlb1 = V List Box(
		lb1 = List Box(
			windows, 	//populate the listbox with data table names
			
			//here is the script that runs each time someone clicks in the top box
			//delete the current column list box, if it exists
			Try( lb2 &amp;lt;&amp;lt; delete );				
			
			//append a new col list box, with all columns of the data table selected in the listbox
			vlb1 &amp;lt;&amp;lt; append( lb2 = Filter Col Selector( Data Table( (lb1 &amp;lt;&amp;lt; get selected)[1] ), all ) );
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="截屏2021-09-04 上午11.40.41.png" style="width: 134px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35535i613AE385850582D5/image-size/small?v=v2&amp;amp;px=200" role="button" title="截屏2021-09-04 上午11.40.41.png" alt="截屏2021-09-04 上午11.40.41.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Sep 2021 03:47:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415518#M66457</guid>
      <dc:creator>蘇71</dc:creator>
      <dc:date>2021-09-04T03:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically List Column names of Selected Data Table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415548#M66463</link>
      <description>&lt;P&gt;Quickly looking at this there are two things that must be taken care of when using Filter Col Selector:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;It seems like Filter Col Selector always uses the Current Data table() and you cannot give it direct reference to the datatable you want to use. Based on the Scripting Index it should accept Datatable(name) as argument so most likely a bug (at least in JMP16.1).&lt;/LI&gt;&lt;LI&gt;The red triangle of Filter Col Box is a different DisplayBox which has to be deleted.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;To work around the reference thing you could try changing the Current Data Table() based on the user selection and to delete also the red triangle, you can wrap Filter Col Box around V List Box and delete that.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

//get a list of window names
windows = Get Data Table List();

/*remove ones that are not data tables--need to start at back of list, because its length will change as we delete items
For( i = N Items( windows ), i &amp;gt; 0, i--,
	If( (Window( windows[i] ) &amp;lt;&amp;lt; Window Class Name) != "DataTable",
		Remove From( windows, i )
	)
);
*/
//make a dialog window
nw = New Window("Sample",
	vlb1 = V List Box(
		lb1 = List Box(
			windows, 	//populate the listbox with data table names
			
			//here is the script that runs each time someone clicks in the top box
			//delete the current column list box, if it exists
			Try(vlb2 &amp;lt;&amp;lt; delete);				
			
			//append a new v list box which includes filter col selector 
			Current Data Table(Data Table((lb1 &amp;lt;&amp;lt; get selected)[1]));
			vlb1 &amp;lt;&amp;lt; append(vlb2 = V List Box(Filter Col Selector()));
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Also here is simple script to replicate the issue with Filter Col Selector:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
//Open two data tables
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Consumer Preferences.jmp");

//Make sure the one not used in filter col selector is current data table
Current Data Table(dt2);
wait(0);

//Create filter col selector with non current data table
New Window("Filter Col Selector Example",
	fontobj = lb = Filter Col Selector(Data table("Big Class"))
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Sep 2021 07:16:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415548#M66463</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-09-04T07:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically List Column names of Selected Data Table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415983#M66525</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
//Open two data tables
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Consumer Preferences.jmp");

//Make sure the one not used in filter col selector is current data table
Current Data Table(dt2);
wait(0);

//Create filter col selector with non current data table
New Window("Filter Col Selector Example",
	fontobj = lb = Filter Col Selector(Data table(dt)) //replace "big class" with dt work.
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Replace data table("big class") with data table (dt),it work.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 13:13:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-Dynamically-List-Column-names-of-Selected-Data-Table/m-p/415983#M66525</guid>
      <dc:creator>蘇71</dc:creator>
      <dc:date>2021-09-07T13:13:06Z</dc:date>
    </item>
  </channel>
</rss>

