Page 2 of 2

Re: Browse Form color row

Posted: Thu Dec 15, 2022 3:13 pm
by vanman
Thanks

Ok so if the condition is being met in the JS where do you suggest I start to troubleshoot?

Paul

Re: Browse Form color row

Posted: Thu Dec 15, 2022 4:22 pm
by kev1n
vanman wrote: Thu Dec 15, 2022 2:51 pm $s1 = "IF(dle_ent_date BETWEEN '$today' AND '$days6', CONCAT('<div class=\"$green\">', ";
$s2 = ",'</div>'), IF(dle_ent_date BETWEEN '$days7' AND '$days13', CONCAT('<div class=\"$orange\">', ";
$s3 = ",'</div>'),";
$s4 = ")) ";
<div> will create a child element within the cell. Therefore you'll need to apply the new style to the child elements es well.

Instead of

Code: Select all

$("div[id^='nucell_" + row + "']").css("background-color", "#008000");
Write

Code: Select all

    const cells = $("div[id^='nucell_" + row + "']");
    cells.addClass('red');
    cells.children().addClass('red');
In the code above, I added a class instead of inline css, which looks like

Code: Select all

.red {
   background-color: red !important;
   color: #ffffff;
}

Re: Browse Form color row

Posted: Fri Dec 16, 2022 11:24 am
by vanman
Thank You

Re: Browse Form color row

Posted: Fri Mar 17, 2023 10:37 am
by plata
Hi,

I tried a slightly altered version of Kev1n's code from this thread and some of my rows get the wrong background-color.
My JS skills are basically non-existent so i have no idea what is wrong.
code.png
highlight_initial.png

Additional observation: when sorting in the browse form by the column used in the condition in ascending order all rows get the conditional background-color applied.
When sorting in descending order all background-colors are correct.
highlight_sorted_ascending.png
highlight_sorted_descending.png
I tested with firefox and qutebrowser (QtWebEngine).
Any ideas :) ?

Re: Browse Form color row

Posted: Fri Mar 17, 2023 11:03 am
by kev1n
Give this a go:

Code: Select all

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

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

Re: Browse Form color row

Posted: Fri Mar 17, 2023 1:17 pm
by plata
Awesome, thanks.
You're the best :)