BookmarkSubscribe
Choose Language Hide Translation Bar
Tzu-Chun
Community Trekker

Subscribe a cell in a data set

Hi all,

 

I was trying to subscribe a cell in a data set, but it never worked. For example, I would like to receive a message onece the value of some particular cells are changed. Here is an example:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Example",
    TB=Table Box(
        Data Table Col Box( :height )
    )
);

TB<<Set Cell Changed Function(
    Function( {this, col, row},
        New window("Warning",
        	text box("The cell value has been changed"),
        )
    )
);

Once I change the values in "height" column, the corresponding value in the data table col box will be chnaged. However, the warning window will not poped up while the value changed. Basicly, I would like to receive messages from data table like Subscribe() did for one/multiple cells. Any ideas will be appriciated.

0 Kudos
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Subscribe a cell in a data set

I am not aware of anyway to directly trigger a change in a data value in a data table, and then get it to affect a change in a Table Box().  However, below is a work around that is a little bit strange, but it does get the job done.........I also hope another member of the JMP Community has a more direct way of solving this problem

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

// Setup a matrix of the current values
holdMatrix = dt:Height << Get Values;

// A Graphics Script will be triggered every time a
// graph changes.  
// Therefore, it can be used to trigger a change in
// a data table
// Open a graph that will have a data point for every
// entry in the data table.  
cc = Control Chart(
	Sample Size( 1 ),
	KSigma( 3 ),
	Chart Col( :height, Run Chart( Show Center Line( 0 ) ) )
);
// The chart is not intended to be displayed, only used as
// a trigger.  Therefore it needs to be hidden.  If an 
// "Invisible" element is added to the chart, the graphics
// trigger does not seem to work, however, if the "show window"
// message is sent, the Graphics Script continues to work
Report( cc ) << show window( 0 );

// Add a script to the Chart, to make the changes in
// the Table Box
Report( cc )[FrameBox( 1 )] << Add Graphics Script(
	ncb << delete;
	tb << append( ncb = Number Col Box( "string", dt:height << get values ) );
	
	// If any value in the data tables Height column changes, 
	// this If statement will detect it
	If( Min( holdMatrix == dt:height << get values ) == 0,
		New Window( "Warning", Text Box( "The cell value has been changed" ), );
		holdMatrix = dt:height << get values;
	);
);

// Open the display window, with the desired table box
nw = New Window( "Example",
	TB = Table Box(
		ncb = Number Col Box( "string", dt:height << get values ), 

	)
);

// When the display window is closed, cleanup the 
// environment by closing the trigger chart
nw << on close( Report( cc ) << close window );
Jim
0 Kudos
ms
Super User ms
Super User

Re: Subscribe a cell in a data set

The "Set Cell Changed Function" seems not to work for Data Table Col Box(), in spite of being listed in the Scripting Index. 

 

Here's an idea for workaround besed on two (hidden) columns in the data table.

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("orig_height", values(:height << get values), hide(1));
dt << New Column("on_change",
    Formula(
        If(height != orig_height,
            New Window("Warning", Text Box("The cell value has been changed"));
            .;
        )
    ),
    hide(1)
);
New Window("Example", Table Box(dtcb = Data Table Col Box(:height)));
6 REPLIES 6
txnelson
Super User

Re: Subscribe a cell in a data set

The issue seems to be that you are not using an editable Col Box() for the table.  I have changed your Data Table Col Box() to a Number Col Edit Box() and the functionallity you specified now works.

names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Example",
    TB=Table Box(
		number Col Edit Box( "string",dt:height<<get values ),
    )
);

TB<<Set Cell Changed Function(
    Function( {this, col, row},
        New window("Warning",
        	text box("The cell value has been changed"),
        )
    )
);
Jim
Highlighted
Tzu-Chun
Community Trekker

Re: Subscribe a cell in a data set

Hi Jim,

 

Thanks for your great idea. However, I was trying to do the same thing as the data table col box did - link a value from data table once the value of a certain cell changed. So, the data will be updated directly to the data table instead of keyin from users. Sorry for the confusion.

 

Tzu-Chun

0 Kudos
txnelson
Super User

Re: Subscribe a cell in a data set

I am not aware of anyway to directly trigger a change in a data value in a data table, and then get it to affect a change in a Table Box().  However, below is a work around that is a little bit strange, but it does get the job done.........I also hope another member of the JMP Community has a more direct way of solving this problem

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

// Setup a matrix of the current values
holdMatrix = dt:Height << Get Values;

// A Graphics Script will be triggered every time a
// graph changes.  
// Therefore, it can be used to trigger a change in
// a data table
// Open a graph that will have a data point for every
// entry in the data table.  
cc = Control Chart(
	Sample Size( 1 ),
	KSigma( 3 ),
	Chart Col( :height, Run Chart( Show Center Line( 0 ) ) )
);
// The chart is not intended to be displayed, only used as
// a trigger.  Therefore it needs to be hidden.  If an 
// "Invisible" element is added to the chart, the graphics
// trigger does not seem to work, however, if the "show window"
// message is sent, the Graphics Script continues to work
Report( cc ) << show window( 0 );

// Add a script to the Chart, to make the changes in
// the Table Box
Report( cc )[FrameBox( 1 )] << Add Graphics Script(
	ncb << delete;
	tb << append( ncb = Number Col Box( "string", dt:height << get values ) );
	
	// If any value in the data tables Height column changes, 
	// this If statement will detect it
	If( Min( holdMatrix == dt:height << get values ) == 0,
		New Window( "Warning", Text Box( "The cell value has been changed" ), );
		holdMatrix = dt:height << get values;
	);
);

// Open the display window, with the desired table box
nw = New Window( "Example",
	TB = Table Box(
		ncb = Number Col Box( "string", dt:height << get values ), 

	)
);

// When the display window is closed, cleanup the 
// environment by closing the trigger chart
nw << on close( Report( cc ) << close window );
Jim
0 Kudos
ms
Super User ms
Super User

Re: Subscribe a cell in a data set

The "Set Cell Changed Function" seems not to work for Data Table Col Box(), in spite of being listed in the Scripting Index. 

 

Here's an idea for workaround besed on two (hidden) columns in the data table.

dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << New Column("orig_height", values(:height << get values), hide(1));
dt << New Column("on_change",
    Formula(
        If(height != orig_height,
            New Window("Warning", Text Box("The cell value has been changed"));
            .;
        )
    ),
    hide(1)
);
New Window("Example", Table Box(dtcb = Data Table Col Box(:height)));
txnelson
Super User

Re: Subscribe a cell in a data set

I like it!

Jim
0 Kudos
Tzu-Chun
Community Trekker

Re: Subscribe a cell in a data set

Those two solutions are great and works for me. Thanks again for help and it really helps me a lot!
0 Kudos