Table Cells and addCssClass()

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

geadon
Ebase User
Posts: 67
Joined: Wed Aug 15, 2012 1:22 pm

Table Cells and addCssClass()

#1

Postby geadon » Fri Nov 23, 2018 12:09 pm

I have a table which has a column for priority (high, medium, low). I want to highlight the 'High' priority with a red background and white text.

I can get this to work by doing this:

Code: Select all

var col = controls.colPriority;
var rows = table.getRows();
while(rows.next()) {
	switch(table.Priority.value) {
		case "High":
			col.backgroundColor = "red";
			col.textColor = "white"
		break;
		case "Medium":
			col.backgroundColor = "orange";
			col.textColor = "black"
		break;
		case "Low":
			col.backgroundColor = "green";
			col.textColor = "white"
		break;
	}
}
But I would ideally like to do this via CSS by adding a class to the cell, but it doesn't seem to work. When I inspect the page, no classes have been added to the element.

Code: Select all

var col = controls.colPriority;
var rows = table.getRows();
while(rows.next()) {
	switch(table.Priority.value) {
		case "High":
			col.addCssClass('bg-danger text-white');
		break;
		case "Medium":
			col.addCssClass('bg-warning text-white');
		break;
		case "Low":
			col.addCssClass('bg-success text-white');
		break;
	}
}
Any advice?
0 x

geadon
Ebase User
Posts: 67
Joined: Wed Aug 15, 2012 1:22 pm

Re: Table Cells and addCssClass()

#2

Postby geadon » Fri Nov 23, 2018 12:17 pm

Sorry!

Just had a thought as I walked off to get a cup of tea so turned around and went back to my computer to find 'col.setColumnCellClass()' :oops:

This works for anyone else who may be interested:

Code: Select all

var col = controls.colPriority;
var rows = table.getRows();
while(rows.next()) {
	switch(table.Priority.value) {
		case "High":
			col.setColumnCellClass('bg-danger text-white');
		break;
		case "Medium":
			col.setColumnCellClass('bg-warning text-white');
		break;
		case "Low":
			col.setColumnCellClass('bg-success text-white');
		break;
	}
}
0 x


Who is online

Users browsing this forum: Google [Bot] and 5 guests