cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
hogi
Level XI

Filter Change Handler

I just found out: Make Filter Change handler only works if I store the return value in a variable.


Why does 

filter << Make Filter Change Handler( f );

not work? Is there some knowledge behind it that is worth knowing?

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dist = Distribution( Automatic Recalc( 1 ), Continuous Distribution( Column( :POP ) ) );
filter = dist << Local Data Filter( Add Filter( columns( :Region ) ) );
f = Function( {a}, Print( a ) );
// 1st version dosn't work - why?
// filter << Make Filter Change Handler( f );
rs = filter << Make Filter Change Handler( f );
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Filter Change Handler

Hi @hogi - this just came up with someone else recently.  The reason behind the current behavior is that the JSL symbol is the owner of the object that dispatches the callbacks. Unlike platforms that create a window, there is not another clear candidate to take ownership.  This also happens with things like display boxes if you create a box but do not give it a parent or store it to a symbol, it's just less noticeable in that case.  One option would be to put the variable into a window-scope symbol so that it will go away with the report.

View solution in original post

2 REPLIES 2

Re: Filter Change Handler

Hi @hogi - this just came up with someone else recently.  The reason behind the current behavior is that the JSL symbol is the owner of the object that dispatches the callbacks. Unlike platforms that create a window, there is not another clear candidate to take ownership.  This also happens with things like display boxes if you create a box but do not give it a parent or store it to a symbol, it's just less noticeable in that case.  One option would be to put the variable into a window-scope symbol so that it will go away with the report.

hogi
Level XI

Re: Filter Change Handler

Hi @danschikore, thank you for the reply.


I noticed that a Data Filter which is opened from a Graph Builder object always triggers the function twice - while a Data filter in a Data Filter Context Box just triggers the function 1x.

And if you disable the

count excluded rows

of the "inner" Data Filter then you can watch some ping-pong between both data filters.

 

What is the reason for the function calls with return value 0?

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
countexcluded = 1;

New Window( "Big Class - Dashboard",
	Data Filter Context Box(
		Panel Box( "Data Filter Context Box: Data Filter + GraphBuilder",
			H Splitter Box(
				Size( 700, 400 ),
				<<Sizes( {0.3, 0.7} ), 

				dt << Data Filter( Local, Add Filter( columns( :sex ) ) ),
				Panel Box( "Graph builder + local data fitler",
					V List Box(
						Button Box( "toggle count excluded",
							countexcluded = Not( countexcluded );
							(Current Report()[Panel Box( 2 )]["Local Data Filter"] << get scriptable object()) <<
							count excluded rows( countexcluded );
						),
						gb = dt << Graph Builder(
							Size( 211, 211 ),
							Show Control Panel( 0 ),
							Fit to Window,
							Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
							Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) ),
							Local Data Filter( Add Filter( columns( :age ) ) )
						)
					)
				)
			)
		)
	)
);

dfs = (Current Report() << XPath( "//OutlineBox[text()='Local Data Filter']" )) << get scriptable object();

f1 = Function( {a}, write("outer: ",  a,"\!n" ) );
f2 = Function( {a}, write("inner: ",  a,"\!n" ) );


rs1 = dfs[1] << Make Filter Change Handler( f1 );
rs2 = dfs[2] << Make Filter Change Handler( f2 );