cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
twalk
Level II

Sort order in custom sort window

How does the JMP Sort window pass ascending and descending from the buttons to the Col List Box (ListBoxBox?) to the OK button?

 

I need to make a custom sort window with limited options for data tables in a report.  I figured out how to do most of it, either building up a sort window from scratch, or starting with the JMP sort window. An example with the latter follows.

 

How do I get order_list == ????????; from the Sort Window?

Getting the columns to sort by is easy with Get Items. How do I get the directions that are associated with the ascending and descending icons appearing before the data type and column name in the Column List Box?

 

custom_sort_window.png

 

Here is a sample code.

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Sort(dt);

sort_window = Get Window( "Sort" );
sort_window[1][1][1][3][1] << Delete Box();
sort_window[1][1][1][2][1][2] << Delete Box();
sort_window[1][1][1][2][3][1][5] << Delete Box();
sort_window[1][1][1][2][3][1][4] << Delete Box();
sort_window[1][1][1][2][3][1][3] << Delete Box();
sort_window[1][1][1][2][3][1][2] << Delete Box();
sort_window[1][1][1][2][3][1][1] << Delete Box();
sort_window[1][1][1][2][2][2] << Delete Box();

selected_column_box = sort_window[1][1][1][2][2][1][1][2];

sort_window[1][1][1][2][3][1] << append( Button Box( "     OK     ",
    Print("OK clicked");
    sel_list = selected_column_box << Get Items;
    sel_string = sel_list[1];
    For( i = 2, i <= N Items(sel_list), i++,
     	sel_string = sel_string || ", " || sel_list[i]
    );
    //// For Testing
//    order_list = {"Ascending", "Ascending"};
    order_list == ????????;
    order_string = order_list[1];
    For( i = 2, i <= N Items(order_list), i++,
       	order_string = order_string || ", " || order_list[i]
    );

    sort_statement = "dt << Sort( By(^sel_string^), Order(^order_string^),  Replace Table);";
    Eval Insert Into( sort_statement );
	Eval( Parse( sort_statement ) );
    , <<Set Icon("RunTableScriptHover");
) );
sort_window[1][1][1][2][3][1] << append( Button box("  Cancel  ",
	sort_window << Close Window;
	Print( "Close Sort Window" ), <<Set Icon("TabClosePress");
) );
 

 Thanks for any suggestions.

 

1 REPLY 1
twalk
Level II

Re: Sort order in custom sort window

Thanks to Wendy Murphrey in JMP technical support for giving me suggestions to help me do what I want.

 

Though I am still interested in knowing how ascending and descending are accessed by elements of the sort window, I don't need it. Anybody who has an answer to that question, please feel free to let me know.

 

Be that as it may, my objective is to sort tables in report tabs. These tables are linked to invisible tables where the sorting is actually done. However, I have to force replacing tables, so that users are not creating tons of untracked tables when working in the reports.

 

Leaving aside all of the report creation and managing report tables in tabs, here is an update on the heart of sorting background invisible tables that should work for our report tables.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Sort(dt);

sort_window = Get Window( "Sort" );

// For stability, collapse, don't delete window elements
sort_window[1][1][1][3][1] << Visibility( "Collapse" );
sort_window[1][1][1][2][3][1][4] << Visibility( "Collapse" );
sort_window[1][1][1][2][2][2] << Visibility( "Collapse" );
sort_window[1][1][1][2][1][2] << Visibility( "Collapse" );

sort_window << OnClose(
    dt1 = Get Data Table( 1 );
   // Include name check in case users figure out a way
   // to replace tables themselves, despite collapsing that option above
    old_name = dt << Get Name();
    new_name = dt1 << Get Name();
    if( new_name != old_name, 
        dt << Update( With( dt1 ) );
        Close(dt1, "No Save")  
    );    
);