Community Trekker

Joined:

Jun 29, 2012

## How to automatically call a function when a column is modified?

I have a character column in a data table which allows the user to change the data via a list check. The column is prefilled with values and I need a way to detect when the user changes a value in the column so I can call a function that re-colors the rows accordingly. Subscribing to the datatable won't work because I need to detect changes in existing rows and not the addition of new ones. Is there some way to do this with MakeRowStateHandler? I made an attempt but ended up with too many recursions because the called function actually changes the row states and this re-triggers the row state handler.

1 ACCEPTED SOLUTION

Accepted Solutions

Super User

Joined:

Jun 23, 2011

Solution

## Re: How to automatically call a function when a column is modified?

This is a bit of a kluge but should work:

Let's suppose your character column is called A.

Create two hidden columns, B and C:

1. B is a copy of column A

2. C is a formula column who's formula is:

a. Do the two columns A and B have the same value?

b. If yes do nothing.

c. If no call your function, and then set the B equal to the new value of A

You might get some ideas on formula columns for step 2 from my poster: http://www.jmp.com/about/events/summit2011/protected/Poster11_PeterMroz.pdf

See section 4, where a table cell acts like a hyperlink.  This approach might not be what you need, as I needed the user to just click on a column cell for things to happen.

2 REPLIES

Super User

Joined:

Jun 23, 2011

Solution

## Re: How to automatically call a function when a column is modified?

This is a bit of a kluge but should work:

Let's suppose your character column is called A.

Create two hidden columns, B and C:

1. B is a copy of column A

2. C is a formula column who's formula is:

a. Do the two columns A and B have the same value?

b. If yes do nothing.

c. If no call your function, and then set the B equal to the new value of A

You might get some ideas on formula columns for step 2 from my poster: http://www.jmp.com/about/events/summit2011/protected/Poster11_PeterMroz.pdf

See section 4, where a table cell acts like a hyperlink.  This approach might not be what you need, as I needed the user to just click on a column cell for things to happen.

Community Trekker

Joined:

Jun 29, 2012

## Re: How to automatically call a function when a column is modified?

Thank you! This solution works!