0

I want to change font and color of a specific cell in a ListGrid.

I succeeded to change the color of the entire row with the following lines, but not of a single row:

for (ListGrid table : tables)
{
ListGridField[] columns = table.getFields(); 
for (Record record : table.getRecords())
    {
       ....
       record.setAttribute("cssText",
                           "font-weight:bold; font-size:80%; color:#FF3300;");

I don't want to use getCellCSSText function, i tried the following but it didn't work:

ListGridField gridfield = table.getField(columns[1].getName());
gridfield.setAttribute("cssText", 
                       "font-weight:bold; font-size:80%; color:#FF3300;");
table.refreshFields();
Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
yaron
  • 439
  • 6
  • 16
  • 1
    You should accept more answers to previous questions, to increase the change of getting a good answer to this question... – Hidde May 20 '12 at 12:54
  • I accepted answer that helped me. – yaron May 20 '12 at 17:09
  • If no more than 60% of the answers to your questions helped you, I think either the way you asked the questions is not right, or you just don't except the correct answers because people didn't write your code for you. – Hidde May 20 '12 at 19:33
  • @Hiddle I'll note what you said. Although, i don't accept my own answers! – yaron May 21 '12 at 07:13
  • Why you don't want to use the getCellCSSText function? It seems to me it is the nominal way to achieve your requirement. – gpapaz May 22 '12 at 12:58
  • @gpapaz I don't want to use this one because, to set the color i need an external parameter. I have no problem using it, if there is a way to attach a value to each cell. A value that is not displayed. And not the way i did it : by hiding a column – yaron May 22 '12 at 15:24

1 Answers1

0

I'm sure there is a better way to do it. But this is how i did it:

  1. I added a hidden column to the table, that contain the color.

  2. In getCellCSSText i read the color and the column name and set the color.

Is there a way to add an invisible parameter to a ListGridRecord? So that i won't add an entire column.

yaron
  • 439
  • 6
  • 16