Welcome to the nuBuilder Forums!

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

Change of row / column color

Questions related to using nuBuilder Forte.
Post Reply
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Change of row / column color

Unread post by Janusz »

Hi,
for specific rows color change in browse form I can use the code as below, from one of the topic disscussed before on the forum - and it works fine.

but the question I have is:
Can you give some tips how to change the complete column color (from the very top to the bottom in browse form) ?

Code: Select all

if (nuFormType() == 'browse') {
    $('[data-nu-column="2"]').each(function (index) {
        var cellId = $(this).attr('id');
        var cellValue = $('#' + cellId).html();
        var rowNum = String(cellId).split('_')[1];
        if (cellValue == "completed") {
$("div[id^='nucell_" + rowNum + "']").css("color", "blue");
}
        else {
 } });}
Last edited by Janusz on Thu Mar 07, 2019 5:23 pm, edited 1 time in total.
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Change of column color

Unread post by kev1n »

To color row 3 (0 = first column):

Code: Select all

$('[id^=nucell_][id $=_2]').css("color", "blue");
$('#nusort_2').css("color", "blue");
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Change of column color

Unread post by Janusz »

Thanks, it's working well.

Additionally I added in the else statement color black as I noticed that after some time some lines were staying blue and it should not.

Code: Select all

.....
$("div[id^='nucell_" + rowNum + "']").css("color", "blue");
}
        else {
$("div[id^='nucell_" + rowNum + "']").css("color", "black");
}
....
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Change of column color

Unread post by kev1n »

You're right, I noticed that too.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Change of column color

Unread post by Janusz »

Hi,
Is it possible to extend the code which reads one cell in the raw to be able to read at the same time 2 column values per raw?

Code: Select all

if (nuFormType() == 'browse') {
    $('[data-nu-column="2"]').each(function (index) {
        var cellId = $(this).attr('id');
        var cellValue = $('#' + cellId).html();
.......
I mean to have something like this (but of course the code belowe does not work):

Code: Select all

if (nuFormType() == 'browse') {
    $('[data-nu-column="2,4"]').each(function (index) {
        var cellId1 = $(this).attr('id[0]');
        var cellValue1 = $('#' + cellId1).html();
              var cellId2 = $(this).attr('id[1]');
              var cellValue2 = $('#' + cellId2).html();
.......
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: Change of column color

Unread post by kev1n »

Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: Change of row / column color

Unread post by Janusz »

Hi Kev1n,
Thanks for info.

and maybe if somene would need similar solution please find enclosed the code for 2 columns - and can be extended for more columns,

Code: Select all

// begin
var col_A = "5";    // column A
var col_B = "2";    // column B

$('[data-nu-column="'+col_A+'"]').each(function (index) { 
 
    var id_A = $(this).attr('id'); // id of column A
    var cellvalue_A = $('#' + id_A).html(); // value of column A

    var id_B = id_A.substring(0, id_A.lastIndexOf('_') + 1) + col_B; 
    var cellvalue_B = $('#' + id_B).html(); // value of column B

 
var rowNum = String(id_A).split('_')[1];

        if (cellvalue_A == "any_text1") {
$("div[id^='nucell_" + rowNum + "']").css("color", "blue");
}

        else if (cellvalue_B == "any_text2") {
$("div[id^='nucell_" + rowNum + "']").css("color", "Crimson");
}

        else {
$("div[id^='nucell_" + rowNum + "']").css("color", "black");
 } 

}

//end
If you like nuBuilder, please leave a review on SourceForge
Post Reply