Conditional Formatting Child Table on Change?

Hello,

is it possible to dynamically change the format of a child table (text or cell colour) when a value is entered/changed in the table?

I had tried the following code but it isn’t dynamically changing the fields as hoped.

frappe.ui.form.on('Purchase Receipt', {
	    onload: function(frm, cdt, cdn) {
		    cur_frm.fields_dict.items.$wrapper.find('.grid-body .rows').find(".grid-row").each(function(i, item) {
	            let d = locals[cur_frm.fields_dict["items"].grid.doctype][$(item).attr('data-name')];
	            if(d.rejected_qty > 0){
		            $(item).find('.grid-static-col').css({'color': '#FF0000'});

	            }
	            

        });
        frm.refresh_field('items');
	    }
});

Thanks,
Paul