I successfully followed the JqxGrid example shown on this site.
I put the CSS code shown in the top right corner (colour info) on that site in the NSB project CSS.
Instead of having fixed CSS, i need to be able to change colours based on what the user selects. Is there a way to do this? Such as store the colours in an array to then be used as required?
Essentially, i need to change the colour of the individual cell. With the website sample, they set the cell colours using:
var cellclass = function(row, columnfield, value) {
if (value < 3) {
return ‘red’;
} else if (value >= 3 && value < 8) {
return ‘yellow’;
} else return ‘green’;
};
Then the CSS is as follows:
.green {
color: black !important;
background-color: #b6ff00 !important;
}
.yellow {
color: black !important;
background-color: yellow !important;
}
.red {
color: black !important;
background-color: #e83636 !important;
}
I made it work in NSB by putting the CSS above in the project CSS. However, i need to be able to change the colours at runtime and that is what i am not sure about.
Can the colour be defined in a variable at runtime then applied that way instead of putting it in project css?
Instead of using the colorpicker, i put 25 buttons on a form and each of them has a different colour, and associated class that i put in CSS.
When each row of the grid array is filled, i have another array that only stores the colour class for that row. When the cellclass is called, i know the row number so from the colour array, i know the class and return the colour.