Page 1 of 1

javascript code

Posted: Tue Oct 15, 2024 3:56 pm
by ricklincs
I use the following on custom code browse and edit to make the row yellow if the 8th column value is 1. (Think I got this off Ke1vin1)

Code: Select all

function rowYellow2() {
  $('[data-nu-column="7"]').each(function () {
    const cell = $(this);
    const row = cell.attr("data-nu-row");
    if (cell.html() === "1") {
      $('[data-nu-row="' + row + '"]').css("background-color", "#FFE9A5");
    }
  });
}

if (nuFormType() === 'browse') {
  rowYellow2();
}
I would like to do the same on another browse form but this time the column has a date value, I would like to make the row yellow if the date value is 90 days or more than the current date, my javascript skills are limited and have tried using ChatGPT but seem to be getting more and more javascript errors. Anybody any samples of this kind of javascript? Thanks in advance.

Re: javascript code

Posted: Tue Oct 15, 2024 10:21 pm
by steven
Hi ricklincs,

The trick is getting one of the fields in your Browse to calculate the date difference (and maybe hide this column).

browse.png

So you get something like this...

select.png

Then you should be able to select the hidden column. And change the html value you are looking for.

code2.png

Code: Select all


function rowYellow2() {
    
    $('[data-nu-column="3"]').each(function () {
    
        const cell = $(this);
        const row = cell.attr("data-nu-row");
    
        if (cell.html() > "90") {   //-- over 90 days
            $('[data-nu-row="' + row + '"]').css("background-color", "#FFE9A5");
        }
        
    });

}


if (nuFormType() === 'browse') {
    rowYellow2();
}



Steven

Re: javascript code

Posted: Wed Oct 16, 2024 8:20 am
by ricklincs
Thanks Steven. That's great.