<?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: Make Row State Handler stops working if table is sorted in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654171#M84347</link>
    <description>&lt;P&gt;Hi Brady, this is brilliant, thank you! This has given me a much more robust and usable solution that I had before.&lt;/P&gt;&lt;P&gt;One question: is it possible to query the Data Table Box from JSL to find out which column (if any) the user has sorted the table by?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Matthew.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 18:41:17 GMT</pubDate>
    <dc:creator>matth1</dc:creator>
    <dc:date>2023-06-29T18:41:17Z</dc:date>
    <item>
      <title>Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/643826#M84062</link>
      <description>&lt;P&gt;Is it possible to apply a row state handler to a data table and make that handler continue to work if the data table is changed; for example, if a column is sorted by a script or interactively by a user?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have two tables of data: one table with summary statistics, one with raw data. The user selects a row in the summary table, the row state handler detects which row is selected, extracts the parameter name and creates a chart from the raw data table using the parameter selected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works OK (although it does pick up the row that's been deselected at first before then finding the newly selected row), however it breaks if the user sorts the summary table (e.g. if they want to look at lowest Cpk, or some other metric).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see the same issue in the following simple example based on the scripting help:&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 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
f = Function( {a}, Print( a ) );
rs = dt &amp;lt;&amp;lt; make row state handler( f );
dt &amp;lt;&amp;lt; Select Rows( 1 );
dt &amp;lt;&amp;lt; sort( by( :weight ), replace table, order( ascending ) );
dt &amp;lt;&amp;lt; Select Rows( 9 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Output is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Scriptable[]
[1]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think this may be related to this wish list item:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Improve-JMP-s-state-handlers-hover-label-row-state-handler/idi-p/527992" target="_blank"&gt;https://community.jmp.com/t5/JMP-Wish-List/Improve-JMP-s-state-handlers-hover-label-row-state-handler/idi-p/527992&lt;/A&gt;. Is there any workaround?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using JMP17.0 on MacOS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 09:37:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/643826#M84062</guid>
      <dc:creator>matth1</dc:creator>
      <dc:date>2023-06-19T09:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/644004#M84089</link>
      <description>&lt;P&gt;By the way, I realise that the scripted example I gave could be easily solved by adding&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rs = dt &amp;lt;&amp;lt; make row state handler( f );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;immediately after my Sort() command. It's the interactive case (where a user manually sorts the table by a column then selects a row) that is the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a workaround by adding a script to the table which resets the row state handler:&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 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
f = Function( {a}, Print( a ) );
rs = dt &amp;lt;&amp;lt; make row state handler( f );
dt &amp;lt;&amp;lt; new script("Fix Row State Handler",
	rs = dt &amp;lt;&amp;lt; make row state handler( f );
); // errors when the script is run!
dt &amp;lt;&amp;lt; Select Rows( 1 );
wait(0);
dt &amp;lt;&amp;lt; sort( by( :weight ), replace table, order( ascending ) );
rs = dt &amp;lt;&amp;lt; make row state handler( f ); // fixes issue when scripting
dt &amp;lt;&amp;lt; Select Rows( 9 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but I get an error when i click the green triangle to run the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Send Expects Scriptable Object in access or evaluation of 'Send' , dt &amp;lt;&amp;lt;  /*###*/make row state handler( f ) /*###*/ at line 6 in ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, even if this worked it would not be ideal since it requires a user to remember to do this after sorting the table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matthew.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 10:52:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/644004#M84089</guid>
      <dc:creator>matth1</dc:creator>
      <dc:date>2023-06-20T10:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654014#M84336</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you can use a report to drive the script. Table boxes can run scripts when rows are selected, and don't seem to break when the summary table is sorted--try the below to get an idea.&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);

dt = open ("$Sample_Data\Car Physical Data.jmp");

dtSum = dt &amp;lt;&amp;lt; summary( group(:Country), mean(:weight) );

nw = new window("ex",
	dtb = Data Table Box( dtSum,
	 &amp;lt;&amp;lt; Set Selectable rows,
	 &amp;lt;&amp;lt; Set Click Sort  )
);

//do something when a row is selected. Here, we just print the country.
dtb &amp;lt;&amp;lt; Set Row Change Function ( function( { this }, 
	selCountry = this[1][this &amp;lt;&amp;lt; get selected rows];
	print(evalinsert("Selected country is: ^selCountry[1]^."))
) );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:20:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654014#M84336</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2023-06-29T15:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654171#M84347</link>
      <description>&lt;P&gt;Hi Brady, this is brilliant, thank you! This has given me a much more robust and usable solution that I had before.&lt;/P&gt;&lt;P&gt;One question: is it possible to query the Data Table Box from JSL to find out which column (if any) the user has sorted the table by?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Matthew.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 18:41:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654171#M84347</guid>
      <dc:creator>matth1</dc:creator>
      <dc:date>2023-06-29T18:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654815#M84391</link>
      <description>&lt;P&gt;Hello Matthew,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know a way to query to see which (if any) column was used to sort the table. You could brute force this by checking the columns, but it may get expensive, depending on table size.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2023 13:55:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/654815#M84391</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2023-07-03T13:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Make Row State Handler stops working if table is sorted</title>
      <link>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/655365#M84449</link>
      <description>&lt;P&gt;Hi Brady,&lt;/P&gt;&lt;P&gt;thanks for the tip.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;I don't know a way to query to see which (if any) column was used to sort the table. You could brute force this by checking the columns, but it may get expensive, depending on table size.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Could you help me with the brute forcing method? I've tried looking at the properties of the DataTableColBox and the window itself and not found anything that helps me see if it's sorted.&lt;BR /&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matthew.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 11:42:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Make-Row-State-Handler-stops-working-if-table-is-sorted/m-p/655365#M84449</guid>
      <dc:creator>matth1</dc:creator>
      <dc:date>2023-07-05T11:42:24Z</dc:date>
    </item>
  </channel>
</rss>

