I created a table according to an sql query
I created a transformer to ensure my columns are properly ordered as I want
I'd like now to color each cell of my table according to its position.
My tables columns stand for month number : 01,02... up to 12.
My tables rows stand for day numbers: 01,02... up to 31.
I've been trying to enhanced my transformer by adding the property "colorMapper" while building my list of columns and passing an expression to it as explained here
here is my transformer
columns=[];
columns.push({"name":"Day","type":"string"});
let d = new Date();
let currentyear = d.getFullYear();
let max_month_index = d.getMonth(); //renvoie un entier en 0 et 11
if ({{year.value}} != currentyear) {
max_month_index = 11; }
for (let i = 0; i <= max_month_index; i++) {
let j=i+1;
let columnJ = (j+'').padStart(2, '0') ;
let m = "{\{(new Date('"+{{year.value}}+"-"+columnJ+"-"+"(currentRow.Day)')).getDay() == 0 ? '#00ff00' : '#ffffff'\}}";
columns.push({"name":columnJ,"type":"number","colorMapper":m});
}
return columns ;
You probably don't need to add the ternary in your data because you can do it within the background field in the column of the table component - If I am reading your question correctly {{currentRow.05 == 'Sunday'?'#00ff00':''}}
Can you post a screenshot of your table - and since I don't have context, what exactly is it that you are trying to build? Retool has quite a bit of functionality that should allow you to achieve what you need without so much work....more clarification would help me help you