Unfortunately, I want this in a grid, not on a form… .
I’ve found at least a ‘dirty’ workaround…
I first use OnRecord to set my “active/inactive” button to the correct state according to my ‘hidden’ value (the hidden field IS available to OnRecord). Since my button has an image, I set an ‘alt’ tag to whatever I want.
if ({hiddenfield}=='active') {
{toggleButton} = '<button style=whatever><img src='activebuttonimage.png' alt='buttonIsActive'></button>';
}
Then, Inside the Ajax event, instead of looking for my ‘hidden column’s’ value, I’m using strpos to search for the alt tag’s value, and execute whatever code I need (usually toggling the hidden field), and updating my button’s image.
if (strpos({toggleButton},'buttonIsActive')!=false) { // button is currently active
$sql="UPDATE table SET hiddenfield='inactive' WHERE whatever"; // change table's field (hidden on grid) to inactive
{toggleButton} = '<button style=whatever><img src='inactivebuttonimage.png' alt='buttonIsInactive'></button>'; // update the toggle button
} else { // button is inactive
$sql="UPDATE table SET hiddenfield='active' WHERE whatever"; // change table's field (hidden on grid) to Active
{toggleButton} = '<button style=whatever><img src='activebuttonimage.png' alt='buttonIsActive'></button>'; // update the toggle button
}
sc_exec_sql($sql); // execute the needed sql statement
This would be much easier if the hidden field’s value was available to the Ajax Event.
As a sidenote… this method also works better for me for visible fields… since I do not need to do an sc_ajax_refresh();… it works much faster than reloading the whole grid an checking the current visible fields’ value in side the ajax event.