Setting color and background according to a value in a column cell

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Setting color and background according to a value in a column cell

Post by amirvf »

In the detailed view of a list:
1. Is there a way to set the color/background of the text in a column cell, according to its content?
For example to set any cells with the value of "N/A" like this:
Custom Color - 1.jpg
2. Is there a way to set a color/background for the entire row according to the value in a column cell?
For example to set the color of rows containing at least one value of "N/A" like this:
Custom Color - 2.jpg
3. Is there a way to activate a color filter on item name according to the value in a column cell?
For example to set the color of item name in the rows containing at least one value of "N/A" like this:
Custom Color - 3.jpg
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Setting color and background according to a value in a column cell

Post by highend »

1 + 2: Imho not
3: Possible.

Color filter: tags:N/A
but in your case you probably need to use something like this: tags:*N/A*
or maybe tags:*General_Format=N/A*
It depends on the content...

Either turn Configuration | Colors and Styles | Color Filters | Draw background colors as wide as the column
on or off as required
One of my scripts helped you out? Please donate via Paypal

amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Re: Setting color and background according to a value in a column cell

Post by amirvf »

highend wrote: ↑07 Nov 2020 16:50 1 + 2: Imho not
3: Possible.

Color filter: tags:N/A
but in your case you probably need to use something like this: tags:*N/A*
or maybe tags:*General_Format=N/A*
It depends on the content...

Either turn Configuration | Colors and Styles | Color Filters | Draw background colors as wide as the column
on or off as required
It didn't work, since "N/A" is not included in the actual tags. It is just a value which has been returned by the script in the column since MediaInfo CLI has returned an empty value.

I made some modifications to the Custom Columns Script to include "N/A" in the actual tag.

Code: Select all

    $desc = "#::#General_Format=";
    $tagsRaw = tagitems("tags", , <cc_item>);
    $matchesRaw = regexmatches($tagsRaw, "$desc.*?(#::#|$)", <crlf>);

    if ($matchesRaw == "$desc" . "#::#") {
    $tags = replace("$tagsRaw", "$desc", "$desc" . "N/A");
    tag "$tagsRaw" ,<cc_item> , 1, 2;
    tag "$tags" ,<cc_item> , 1, 1;
    $matches = regexmatches($tags, "$desc.*?(#::#|$)", <crlf>);
    } else { $matches = $matchesRaw; }

    $trimmed = replacelist($matches, "$desc<crlf>#::#", "", <crlf>);
    $joined  = replace($trimmed, <crlf>, " - ");
    return $joined;
After above modifications, the following code works as expected:

Code: Select all

tags:*General_Format=N/A*>0053A6,BCCCDE

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Setting color and background according to a value in a column cell

Post by highend »

Way too complicated to do that in a custom column (and slows them down unnecessarily).

The next script version will contain a new key per template: EmptyValue=
By default set to: N/A
the script will replace all empty values with it so it is already in the tag database...

Code: Select all

            // ...
            if ($EmptyValue != "") {
                $result = regexreplace($result, "(#::#[a-z0-9]+?_[a-z0-9]+?=)(#::#|$)", "$1" . $EmptyValue . "$2");
            }
E.g. with this template:

Code: Select all

General=Duration=%Duration/String3%Genre=%Genre%
Video=Format=%Format%Language=%Language%Width=%Width%Height=%Height%
Audio=Language=%Language%
Before:

Code: Select all

#::#General_Duration=00:03:18.925#::#General_Genre=#::#Video_Format=AVC#::#Video_Language=#::#Video_Width=1280#::#Video_Height=720F#::#Audio_Language=
After:

Code: Select all

#::#General_Duration=00:03:18.925#::#General_Genre=N/A#::#Video_Format=AVC#::#Video_Language=N/A#::#Video_Width=1280#::#Video_Height=720F#::#Audio_Language=N/A
One of my scripts helped you out? Please donate via Paypal

amirvf
Posts: 133
Joined: 18 Oct 2020 00:46

Re: Setting color and background according to a value in a column cell

Post by amirvf »

highend wrote: ↑07 Nov 2020 21:56 Way too complicated to do that in a custom column (and slows them down unnecessarily).

The next script version will contain a new key per template: EmptyValue=
If set (manually) to e.g.: N/A
the script will replace all empty values with it so it is already in the tag database...

Code: Select all

            // ...
            if ($EmptyValue != "") {
                $result = regexreplace($result, "(#::#[a-z0-9]+?_[a-z0-9]+?=)(#::#|$)", "$1" . $EmptyValue . "$2");
            }
E.g. with this template:

Code: Select all

General=Duration=%Duration/String3%Genre=%Genre%
Video=Format=%Format%Language=%Language%Width=%Width%Height=%Height%
Audio=Language=%Language%
Before:

Code: Select all

#::#General_Duration=00:03:18.925#::#General_Genre=#::#Video_Format=AVC#::#Video_Language=#::#Video_Width=1280#::#Video_Height=720F#::#Audio_Language=
After:

Code: Select all

#::#General_Duration=00:03:18.925#::#General_Genre=N/A#::#Video_Format=AVC#::#Video_Language=N/A#::#Video_Width=1280#::#Video_Height=720F#::#Audio_Language=N/A
I totally agree. Creating a tag info which already includes all custom defined replacements for the Empty Values is the best solution, as it eliminates the unnecessary delay to re-process the tags for each column.

I'll check the new version and update you on the results.

Post Reply