This topic is locked

Conditional Format of cell background directly after edit

6/24/2021 6:39:09 AM
PHPRunner General questions
Craig Smith author

Hi everyone,

I am trying to do simple conditional format of cell backgrounds of items that have been changed. ie: proposed price does not equal existing price:
I would like the cell background color to change immediately after the user cliks the tick (save) buton.

I have put this in to the After Record Updated event on the edit page for my table:

if ($values['sp_proposed_price'] != $values['sp_new_price_disc'])

I have the same code in the List page (BeforeMoveNextList) function

if ($data['sp_proposed_price'] != $data['sp_new_price_disc'])
else {$record["sp_proposed_price_css"].='background:white';}

This works fine when you refresh the page after making the edit, but i would like the background color to change immediately after the user makes the edit and saves it. Have I done something wrong?

Thanks for any help you can give on this.


admin 6/24/2021

This code in BeforeMoveNextList event will only work once, on the initial page load. You cannot use it to change the color of the cell dynamically without reloading the page.

It is still possible to do what you looking for, it just requires more code and a different approach.

Check this article, section "How to execute JavaScript code after the Inline Add or Edit". It shows how to execute your Javascript code after record was added or edited in the inline mode. You will need to use jQuery's css() function to change the background of the cell.

Craig Smith author 6/27/2021

Thank you for your assistance on this. I was able to to use the article you provided to arrive at a solution.

admin 6/28/2021

Awesome, feel free to share your solution here.

Craig Smith author 7/14/2021

Sorry for the delay on posting the solution:

On the list page for my table, I created the following events:

JavaScript OnLoad event:

if( !pageObj.myAfterInline ) {
this.on('afterInlineEdit', function( fieldsData ) {


} );
pageObj.myAfterInline = true;

List Page: After record processed:

if ($data['sp_proposed_price'] != $data['sp_new_price_disc'])

if ($data['sp_delete'] == 1)

I have three fields in my table that I use to highlight changes to the user - spnewpricedisc, spproposedprice, spdelete.

If the proposed price does not equal the new price, highlight the cell only in yellow.
Also, if the user has checked the delete box, then highlight the whole row in cyan.

When these changes are done using inline edit, the page reloads (using the JavaScript function) and the new conditional formats are applied.

This is a slight adaptation from the article that Sergey pointed me to when replying to my original post.

Hope this helps someone :)

Best regards,