cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lukasz
Level IV

How to update table after sorting?

Hello Everybody,

I have an issue regarding sorting of a table. I wanted to sort table by Date (located in Date1 column) and I am doing that after certain condition is met. However, it does not sort and replace the table EL_summary after sorting. Is there any refreshing necessary? I put also some delay, I thought one need to wait some time. When I am not using replace table(1), the new Table under different name is created and opened (what I don't want) and again data in this table is not sorted. After that, however, data in EL_summary seems to be updated and sorted. I would appreciate for pointing what I am missing. Best regards


Current Data Table( EL_summary );

if( N rows(EL_summary) > 0, EL_summary << sort(by(:name("Date1")), Order( Ascending ), replace table(1)));
wait(1);

 

 

12 REPLIES 12
jthi
Super User

Re: How to update table after sorting?

One option:

  1. Use << Get Window List to get references to all open windows (you can limit this to Type("Reports") if you want to)
  2. Loop over that list and check if there are any which are dependent on the data table being sorted (you should be able to use either the name of the report window OR << Get Data table. If the report belongs to the data table, add it to list
  3. If there are any items in the list, show the message to user
-Jarmo
hogi
Level XII

Re: How to update table after sorting?

Works great thanks

 

closeMyReports = Function( {dt},
	{default local},
	AllmyReports = {};
	myReports = Get Window List( Type( "Reports" ) );
	For Each( {rep}, myReports,
		Try(
			myList = (rep << Xpath( "//OutlineBox" )) << get scriptable Object();
			myDTs = Transform Each( {scriptableObject}, myList, If( Is Empty( scriptableObject ), ., scriptableObject << Get Data Table() ) );
			If( Contains( myDTs, dt ),
				Insert Into( AllmyReports, rep )
			);
		)
	);
	If( N Items( AllmyReports ) > 0,
		If(
			ex = New Window( "",
				<<Type( "Modal Dialog" ),
				<<Return Result,
				V List Box( Text Box( "open reports detected.\!nOK to close them?" ), H List Box( Button Box( "OK" ), Button Box( "Cancel" ) ) )
			);
			ex["button"] == 1;
		,
			AllmyReports << close window(),
			Stop()
		)
	);
);
dt = current data table();
closeMyReports(dt)

 

edit: now the script also checks for more complicated reports with many data tables.

hogi
Level XII

Re: How to update table after sorting?

Next step: is there a command:

dt << get linked subsets()

hogi_1-1690185112674.png