I have two doubts about JavaScripTable...
- First: I Can "customize in run-time" the cell's color?? There are some method that is called in the "onDrawCell" event?? I would like to do something like this: If the cell's value is major then X, the cell color is red, else, the cell color is blue.
- Second: I Can put a litle image with the text in a cell in the JST? A image like a "face happy or unhappy". at news, this face depends of the "cell's value"
Thank's for the help friends!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
The answer to both questions are the same: using custom parsers for those columns.
var LIMIT = 100;
function colorize(number) {
var color = (number > LIMIT) ? "red" : "blue";
return "<span style='color:" + color + "'>" + number + "</span>";
}
function faces(flag) {
var image = flag ? "happy.gif" : "sad.gif";
return "<img src='" + image + "'>";
}
var numberColumn = table.addColumn(...);
numberColumn.parser = new CustomParser(colorize);
var faceColumn = table.addColumn(...);
faceColumn.parser = new CustomParser(faces);
On the example, if you would need a number formatting as well, you would have to build a NumberParser and return "<span style='color:" + color + "'>" + myNumberParser.format(number) + "</span>" instaed.
Hope this helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello friends!
I have two doubts about JavaScripTable...
- First: I Can "customize in run-time" the cell's color?? There are some method that is called in the "onDrawCell" event?? I would like to do something like this: If the cell's value is major then X, the cell color is red, else, the cell color is blue.
- Second: I Can put a litle image with the text in a cell in the JST? A image like a "face happy or unhappy". at news, this face depends of the "cell's value"
Thank's for the help friends!!
Hi!
The answer to both questions are the same: using custom parsers for those columns.
var LIMIT = 100;
function colorize(number) {
var color = (number > LIMIT) ? "red" : "blue";
return "<span style='color:" + color + "'>" + number + "</span>";
}
function faces(flag) {
var image = flag ? "happy.gif" : "sad.gif";
return "<img src='" + image + "'>";
}
var numberColumn = table.addColumn(...);
numberColumn.parser = new CustomParser(colorize);
var faceColumn = table.addColumn(...);
faceColumn.parser = new CustomParser(faces);
On the example, if you would need a number formatting as well, you would have to build a NumberParser and return "<span style='color:" + color + "'>" + myNumberParser.format(number) + "</span>" instaed.
Hope this helps.
Thank's for this help Luis!!
I will try to do this!!!
bye