Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, 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

Browse Form color row

Unread post by vanman »

Hi

Is it possible to color whole row in a browse form based on a date in a column.

I know who to do it for a column but not the whole row

Thanks

Paul
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Browse Form color row

Unread post by kev1n »

Example to color the entire row if the first column matches today's date:

Code: Select all

const today = nuCurrentDate(); // retrieve today's date (format yyyy-mm-dd).
// to pass another format: const today = nuCurrentDate('dd.mm.yyyy');

$('[data-nu-column="0"]').each(function (index) { // 0 = 1st column

    const id = $(this).attr('id');
    const value = $('#' + id).html();
    const row = String(id).split('_')[1];

    if (value == today) {
        $("div[id^='nucell_" + row + "']").css("background-color", "#D4EFDF");
    }

});
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

That was quick
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

Hi Kevin

The row was not colored

used

Code: Select all

$('[data-nu-column="13"]').each(function (index) { // 0 = 1st column

    const id = $(this).attr('id');
    const value = $('#' + id).html();
    const row = String(id).split('_')[1];

    if (String(value) == String(today)) {
        console.log('v: ' + value + ' t: ' + today)
        console.log('r: ' + row);
        $("div[id^='nucell_" + row + "']").css("background-color", "#008000");
    }

});
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

Hi Kevin

If the BB PHP has color code will it override the JS?

Paul
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Browse Form color row

Unread post by kev1n »

I don't understand exactly what you mean. What code does BB contain?
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

HI Kevin

The BB has a temporary table and color based on date conditions for one column.

I notice in JS the console do show when the conditions are met just the rows do not color

Paul
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Browse Form color row

Unread post by kev1n »

vanman wrote: Thu Dec 15, 2022 2:00 pm and color based on date conditions for one column.
What does that look like?
vanman
Posts: 54
Joined: Thu Mar 01, 2018 11:09 pm
Has thanked: 1 time

Re: Browse Form color row

Unread post by vanman »

$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 = ")) ";

Part of the SQL
CREATE TABLE #TABLE_ID#
SELECT
dle_delord_id,
dle_freight_invoice_extra_text,
{$s1}dle_code{$s2}dle_code{$s3}dle_code{$s4} AS dle_code,
{$s1}dle_docket_no{$s2}dle_docket_no{$s3}dle_docket_no{$s4} AS dle_docket_no,
dle_ent_date AS dle_ent_date_disp,
dle_del_date AS dle_del_date_disp
FROM delord
ORDER BY dle_ent_date_disp DESC, dle_del_date_disp DESC
There are more columns

I have taken over the support of the system

DB Version V.4.5-2021.03.25.00
Files Version V.4.5-2021.03.25.00

Customer does not want to upgrade atm

Paul
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Browse Form color row

Unread post by kev1n »

vanman wrote: Wed Dec 14, 2022 10:38 pm Hi Kevin

If the BB PHP has color code will it override the JS?

Paul
JS will override the PHP color codes.
Post Reply