Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Operator to allow 2nd parameter

Firstly please excuse my phrasing here, quite new to JS.
I have the below JS code running and it works perfectly with the parameters set to colour the ‘Assigned Mins’ column in my table.
What I am looking to do is add a 2nd parameter where the same colouring and parmeters but adding a column called ‘Pending’

        for(var i=0; i<columns.length; ++i) {
            if(columns[i].text == 'Assigned Mins') {
                columns[i].renderer = function (value, meta, rec) {
                    if(value > '0:19') {
                        meta.style = "background-color:red;font-weight:bold;color:white;";
                    }
                    else if(value > '0:09') {
                        meta.style = "background-color:orange;font-weight:bold;color:white;";
                    }
                    else {
                        meta.style = "background-color:green;font-weight:bold;color:white;";
                    }
                    return value;

I’ve tried:

            if(columns[i].text == 'Assigned Mins','Pending') {

and

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

            if(columns[i].text == 'Assigned Mins'||'Pending') {

and a few other variations using the || and && operators but either nothing happens or it colours all columns in the table.

As suggested I have also just tried the duplicate post (Check variable equality against a list of values) using:

if (['Assigned Mins','Pending'].indexOf(columns[i]) > -1)

and

if (~['Assigned Mins','Pending'].indexOf(columns[i]))

However in both cases the result is that none of the colouring works at all

Please can someone advise?
Thank you

>Solution :

this should work. It’s the solution you provided but you just forgot the .text

if (['Assigned Mins','Pending'].indexOf(columns[i].text) > -1)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading