3.2.0

setCellText after population to blank

Hi All,

I populate my grid with XML. I would like to chnage the cell text on a column depending on conditions in another column. Basically:

obj.setCellTemplate(new AW.Templates.Text, 1);
obj.setCellText(setText, 1);

function image(col, row){
if (this.getCellValue(14, row) == '0'){
return "ColumnA";
}
}


This doesn't work. Any pointers?

Thanks
John Sourcer
October 12,
obj.setCellText(
      function(col,row) {
        if (col != 1) { return; }
        var v = obj.getCellData(col, row);
        if (v == 5) {
          return "Low";
        } else if (v == 4) {
          return "Medium";
        } else if (v == 3) {
          return "High";
        } else if (v == 2) {
           return "Urgent";
        } else if (v == 1) {
          return "Global";
        } else {
          return "";
        }
      },
      1
    );


This code will change all the text values in column 1 of the grid object 'obj'. To change it to your liking, change the following:

1) var v = obj.getCellData(col, row);
-- change this line and replace col with the foreign column number
2) if (col != 1) { return; }
-- change the 1 to be the number of the column of text you wish changed.
3) 1 (from the second to last line)
-- change this to the number of the column of text you wish changed


In this example it replaces the numbers of priorities with the text. This was great for sorting as it is done on value and not text.
Mike
October 12,
Hi Mike,

Thanks for your reply but I still have trouble as follows:

obj.setCellText(function(col,row) { 
            alert("Hello World!");
            if (col != 1) { return; } 
                var v = obj.getCellData(1, row); 
                if (v == 5) { 
                  return "Low"; 
                } else if (v == 4) { 
                  return "Medium"; 
                } else if (v == 3) { 
                  return "High"; 
                } else if (v == 2) { 
                   return "Urgent"; 
                } else if (v == 1) { 
                  return "Global"; 
                } else { 
                  return ""; 
                } 
            }, 1 
        );


1) Should my 'Hello World' alert fire?
2) You will notice that I am replacing the text in the column that I get the value on. i.e. Column 1 value v change to returned value. Is this ok?
John Sourcer
October 12,
Sorry Mike,

Must be Friday.

As a heads-up to others (although I doubt others woudl be as stupid)

You obviously have to:

obj.setCellModel(table);

BEFORE trying to use obj.setCellText.

John Sourcer
October 13,

This topic is archived.

See also:


Back to support forum