Change of row / column color

Questions related to using nuBuilder Forte.

Change of row / column color

Postby Janusz » Thu Jan 10, 2019 10:06 pm

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 Fri Mar 08, 2019 1:53 am, edited 1 time in total.
Janusz
 
Posts: 88
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Change of column color

Postby kev1n » Thu Jan 10, 2019 10:34 pm

To color row 3 (0 = first column):

Code: Select all
$('[id^=nucell_][id $=_2]').css("color", "blue");
$('#nusort_2').css("color", "blue");
kev1n
 
Posts: 112
Joined: Mon Oct 15, 2018 2:13 am

Re: Change of column color

Postby Janusz » Sat Jan 12, 2019 6:08 pm

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");
}
....
Janusz
 
Posts: 88
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Change of column color

Postby kev1n » Sat Jan 12, 2019 6:10 pm

You're right, I noticed that too.
kev1n
 
Posts: 112
Joined: Mon Oct 15, 2018 2:13 am

Re: Change of column color

Postby Janusz » Thu Mar 07, 2019 2:12 am

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();
.......
Janusz
 
Posts: 88
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Change of column color

Postby kev1n » Thu Mar 07, 2019 4:36 pm

The question here was quite similar:
viewtopic.php?f=20&t=9811
kev1n
 
Posts: 112
Joined: Mon Oct 15, 2018 2:13 am

Re: Change of row / column color

Postby Janusz » Thu Mar 07, 2019 6:55 pm

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
Janusz
 
Posts: 88
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland


Return to General