<?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 sort the data table within an application? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/618461#M81785</link>
    <description>&lt;P&gt;I'm not sure I understand your question correctly, it seems that your script does not contain some character (")" in line 2 and "&amp;lt;&amp;lt;").&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sortThisData = Function( {dt},
	Try( newdt = dt &amp;lt;&amp;lt; Sort( By( Column( snCol ), Column( dtCol ) ), Replace Table ),  );
	/* IF thrown */
	if(contains(exception_msg[1], "JMP cannot replace the existing table"),
		ex = New Window( "Alert",
			&amp;lt;&amp;lt;Modal,
			&amp;lt;&amp;lt;Return Result,
			V List Box(
				H List Box(
					"Set this value",
					fontobj = text = Text Box(
						"JMP cannot replace the existing data table because open report windows depend on the previous ordering."
					)
				),
				Text Box( "" ), 
				V List Box(
					rb = Radio Box(
						{"Continue Without Sorting", "Cancel Script",
						"Create New Sorted Data Table"}
					)
				)
			)
		);
		If(
			ex["rb"] == 1, /*Continue without sorting*/,
			ex["rb"] == 2, /*Stop script*/ (thisModuleInstance &amp;lt;&amp;lt; Get Box) &amp;lt;&amp;lt; Close Window;	Throw();,
			ex["rb"] == 3, /* New data table */ newdt = dt &amp;lt;&amp;lt; Sort( By( Column( snCol ), Column( dtCol ) ), invisible )
		);
	);
	If(ex["rb"]==3, Return( newdt ), Return( dt ););	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 Mar 2023 05:35:14 GMT</pubDate>
    <dc:creator>yuichi_katsumur</dc:creator>
    <dc:date>2023-03-31T05:35:14Z</dc:date>
    <item>
      <title>How to sort the data table within an application?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/617696#M81722</link>
      <description>&lt;P&gt;I've written a fairly complex JSL application using the JMP Application Builder. The application launcher prompts the user for column selections and then I sort the data by the chosen columns before continuing with processing and visualizations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the data set has dependent open windows, I need to give the user the option to continue without sorting (the data was likely pre-sorted) or exit the script to let the user deal with the dependent windows.&amp;nbsp; To this end, I've created the following function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sortThisData = Function ({dt},
	try( dt &amp;lt;&amp;lt; Sort (By( Column(snCol), Column(dtCol)), Replace Table) ,
	/* IF thrown */
	if (contains(exception_msg[1], "JMP cannot replace the existing table"),
			ex = New Window( "Alert", &amp;lt;&amp;lt;Modal, &amp;lt;&amp;lt;Return Result,			
				V List Box( H List Box( "Set this value", 
					fontobj = text = Text Box( "JMP cannot replace the existing data table because open report windows depend on the previous ordering." )),
					Text Box(""),
						//H List Box( Button Box( "Continue Without Sorting" ), Button Box( "Cancel Script" ), Button Box("Create New Sorted Data Table") ) )
						
						V List Box (rb = Radio Box( {"Continue Without Sorting", 
										"Cancel Script", 
										"Create New Sorted Data Table"} ) );
					)
			);
		if (ex["rb"] == 1, /*Continue without sorting*/,
			ex["rb"] == 2, /*Stop script*/ (thisModuleInstance &amp;lt;&amp;lt; Get Box) &amp;lt;&amp;lt; Close Window; stop(),
			ex["rb"] == 3, /* New data table */ dt =  Sort (By(Column(snCol), Column(dtCol)), invisible) 
			)
		)
	);
	return (dt);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it seems that the application itself counts as a dependent open window! I can't sort the data even if no other windows are open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I circumvent this issue and sort my data? I have moved the timing of calling my SORT function, but it needs to happen after the OK button on the launcher was pressed and before the processing/visualizations are done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:06:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/617696#M81722</guid>
      <dc:creator>tLerman</dc:creator>
      <dc:date>2023-06-09T16:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort the data table within an application?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/618461#M81785</link>
      <description>&lt;P&gt;I'm not sure I understand your question correctly, it seems that your script does not contain some character (")" in line 2 and "&amp;lt;&amp;lt;").&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sortThisData = Function( {dt},
	Try( newdt = dt &amp;lt;&amp;lt; Sort( By( Column( snCol ), Column( dtCol ) ), Replace Table ),  );
	/* IF thrown */
	if(contains(exception_msg[1], "JMP cannot replace the existing table"),
		ex = New Window( "Alert",
			&amp;lt;&amp;lt;Modal,
			&amp;lt;&amp;lt;Return Result,
			V List Box(
				H List Box(
					"Set this value",
					fontobj = text = Text Box(
						"JMP cannot replace the existing data table because open report windows depend on the previous ordering."
					)
				),
				Text Box( "" ), 
				V List Box(
					rb = Radio Box(
						{"Continue Without Sorting", "Cancel Script",
						"Create New Sorted Data Table"}
					)
				)
			)
		);
		If(
			ex["rb"] == 1, /*Continue without sorting*/,
			ex["rb"] == 2, /*Stop script*/ (thisModuleInstance &amp;lt;&amp;lt; Get Box) &amp;lt;&amp;lt; Close Window;	Throw();,
			ex["rb"] == 3, /* New data table */ newdt = dt &amp;lt;&amp;lt; Sort( By( Column( snCol ), Column( dtCol ) ), invisible )
		);
	);
	If(ex["rb"]==3, Return( newdt ), Return( dt ););	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Mar 2023 05:35:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/618461#M81785</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-03-31T05:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort the data table within an application?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/619171#M81858</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what you mean by missing characters. But in any case, the issue is the same even if the call to the function above is replaced with a simple Sort Table:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;DataTable1 &amp;lt;&amp;lt; Sort (By( Column(snCol), Column(dtCol)), Replace Table);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the following alert, even though the only open window for DataTable1 is the application that called the Sort function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tLerman_0-1680423779447.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51667i479AFF43C3AF9D4E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tLerman_0-1680423779447.png" alt="tLerman_0-1680423779447.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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 11:10:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/619171#M81858</guid>
      <dc:creator>tLerman</dc:creator>
      <dc:date>2023-04-02T11:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort the data table within an application?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/619231#M81870</link>
      <description>&lt;P&gt;I'm sorry that I have misunderstood what you want to do. It seems that it is not easy to sort a data table in Application Builder.&lt;BR /&gt;It is not a smart solution, you can copy a data table first and then sort the data table. It creates another data table, you should close a table when it is not used.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;original_dt = Current Data Table();
dt =  original_dt &amp;lt;&amp;lt; Subset( All rows, Selected columns only( 0 ), Link to original data table( 0 ), invisible );
dt &amp;lt;&amp;lt; Sort( By( Column( dt, snCol ), Column( dt, dtCol ) ), Replace Table )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2023 04:32:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-sort-the-data-table-within-an-application/m-p/619231#M81870</guid>
      <dc:creator>yuichi_katsumur</dc:creator>
      <dc:date>2023-04-03T04:32:24Z</dc:date>
    </item>
  </channel>
</rss>

