Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Browse Form color row

Questions related to customising nuBuilder Forte with JavaScript or PHP.
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

Thanks

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

Paul
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Browse Form color row

Unread post 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;
}
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

Thank You
plata
Posts: 7
Joined: Tue Nov 08, 2022 7:32 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Browse Form color row

Unread post 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 :) ?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Browse Form color row

Unread post 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();
}
plata
Posts: 7
Joined: Tue Nov 08, 2022 7:32 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Browse Form color row

Unread post by plata »

Awesome, thanks.
You're the best :)
Post Reply