Is it possible to display a data table in a report/layout and have it be dynamic such that as you filter the data, the display only shows the selected items?
I see I can add the data table to a journal window and it will only add the selected rows but I'd like the display to be more dynamic and part of a larger interactive layout I've already built up with other graphs, buttons, and filters.
This can be done, however, there are some complexities.
First, because the data table does not have the ability to make rows invisible, you will have to actually create a new data table with the rows that you don't want displayed, removed from the data table. The New Data Box() or New Data View() that you are displaying will also have to be deleated and appended with the changing of the selections(filter).
The actual data table that the filtering is to be made on can have a Row State Handler, or On Change types of controls used to generate the new tables. Also, I assume, the main data table will be invisible, allowing the user to only see what the New Data Box() is viewing.
This JSL will give you a simple example
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp", invisible );
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible );
nw = New Window( "Filter",
vlb = V List Box(
H List Box(
dt << Data Filter( Location( {2555, 44} ), Add Filter( columns( :sex ) ) ),
dt << Bivariate( Y( :height ), X( :weight ), autocalc( 1 ) )
)
),
dtddis = dtd << New Data Box()
);
nw << onclose( Close( dt, nosave ):close( dtd, nosave ) );
f = Function( {a},
dtddis << delete;
Close( dtd, nosave );
If( N Rows( dt << get selected rows ) > 0,
dtd = dt << subset( selected rows( 1 ), selected columns( 0 ), invisible ),
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible )
);
vlb << append( dtddis = dtd << new data box() );
);
rs = dt << make row state handler( f );
This can be done, however, there are some complexities.
First, because the data table does not have the ability to make rows invisible, you will have to actually create a new data table with the rows that you don't want displayed, removed from the data table. The New Data Box() or New Data View() that you are displaying will also have to be deleated and appended with the changing of the selections(filter).
The actual data table that the filtering is to be made on can have a Row State Handler, or On Change types of controls used to generate the new tables. Also, I assume, the main data table will be invisible, allowing the user to only see what the New Data Box() is viewing.
This JSL will give you a simple example
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp", invisible );
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible );
nw = New Window( "Filter",
vlb = V List Box(
H List Box(
dt << Data Filter( Location( {2555, 44} ), Add Filter( columns( :sex ) ) ),
dt << Bivariate( Y( :height ), X( :weight ), autocalc( 1 ) )
)
),
dtddis = dtd << New Data Box()
);
nw << onclose( Close( dt, nosave ):close( dtd, nosave ) );
f = Function( {a},
dtddis << delete;
Close( dtd, nosave );
If( N Rows( dt << get selected rows ) > 0,
dtd = dt << subset( selected rows( 1 ), selected columns( 0 ), invisible ),
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible )
);
vlb << append( dtddis = dtd << new data box() );
);
rs = dt << make row state handler( f );
Great thanks this is exactly what I needed. I'm encountering one issue however, the formatting of the table within the window is weird. To get the horizontal scroll bar to show up, I have to scroll down to the end of the table within the window. Is there formatting options with the data table box? Would also like to make the text smaller in the table box. Thanks.
you can try placing the New Data Box() inside of a Scroll Box() and see if you can adjust the scroll box sizees to keep the table view to the dimensions you want it. Concerning the font sizes, I am not aware of anyway to reduce them, because that is a global set for all text boxes
Ok that works but it doesn't seem the Size(h,v) inside the scroll box is working correctly. The size of the scroll box is always the same and the Size(h,v) seems to just push out the size of the window when it is first displayed... I'm on JMP 12.2
It appears that if you set the window size of the display window, you will get what you want
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp", invisible );
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible );
nw = New Window( "Filter",
vlb = V List Box(
H List Box(
dt << Data Filter( Location( {2555, 44} ), Add Filter( columns( :sex ) ) ),
dt << Bivariate( Y( :height ), X( :weight ), autocalc( 1 ) )
)
),
dtddis = dtd << New Data Box()
);
nw << set window size(800,800);
nw << onclose( Close( dt, nosave ):close( dtd, nosave ) );
f = Function( {a},
dtddis << delete;
Close( dtd, nosave );
If( N Rows( dt << get selected rows ) > 0,
dtd = dt << subset( selected rows( 1 ), selected columns( 0 ), invisible ),
dtd = dt << subset( selected rows( 0 ), selected columns( 0 ), invisible )
);
vlb << append( dtddis = dtd << new data box() );
);
rs = dt << make row state handler( f );
That's not working for me. The width of the Scrollbox (which I put around the data table box) is always the same. This just changes the size of the window creating a bunch of blank space. The Size(h,v) within the scrollbox function does the same...
Ok I figured it out. I used Data Table Box() instead of << New Data Box() and it doesn't have the scroll bar issues without using scrollbox. Still I think the scollbox() function has an issue with size(h,v).
good find