Page 1 of 1

Change of row / column color

Posted: Thu Jan 10, 2019 1:36 pm
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 {
 } });}

Re: Change of column color

Posted: Thu Jan 10, 2019 2:04 pm
by kev1n
To color row 3 (0 = first column):

Code: Select all

$('[id^=nucell_][id $=_2]').css("color", "blue");
$('#nusort_2').css("color", "blue");

Re: Change of column color

Posted: Sat Jan 12, 2019 9:38 am
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");
}
....

Re: Change of column color

Posted: Sat Jan 12, 2019 9:40 am
by kev1n
You're right, I noticed that too.

Re: Change of column color

Posted: Wed Mar 06, 2019 5:42 pm
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();
.......

Re: Change of column color

Posted: Thu Mar 07, 2019 8:06 am
by kev1n

Re: Change of row / column color

Posted: Thu Mar 07, 2019 10:25 am
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