3.2.0

Why does setCellText vs setCellData behave differently?

Why does this alert work?

obj.setCellText(function(col,row) {
            if (this.getCellValue(15, row) == 'true'){
                alert("true");
              }
        }, 5);


And this one not?


obj.setCellData(function(col,row) {
            if (this.getCellValue(15, row) == 'true'){
                alert("true");
              }
        }, 5);

John Sourcer
October 16,
Nope! I just don't get it!!!

Can someone please explain to me the following:

I have a 'currency' column in my source data, unformatted. I would like to format it using:

var money = new AW.Formats.Number;  
            money.setTextFormat("#,###.##");


So I have to use setCellData, correct. I also would like to run a method on it to check whether I should possibly blank the cell, in order to do this I have to use setCellText!!! WTF? How am I supposed to do this?

This alerts BUT I have no formatting:

obj.setCellText(function(col,row) {
     alert(this.getCellText(5, row));
     }, 5);


This doesn't alert BUT I have formatting:

obj.setCellData(function(col,row) {
     alert(this.getCellText(5, row));
     }, 5);
John Sourcer
October 16,
Anyone? Alex?
John Sourcer
October 17,
When you assign something to the cell data property - the cell text property is adjusted to return the text calculated from the cell data (using cell format object). Here is the code -

function dataToText(i, j){
    var data = this.getCellData(i, j);
    var format = this.getCellFormat(i, j);
    return format ? format.dataToText(data) : data;
}

this.setCellText(dataToText);


You can use similar code to add your own processing on top of the standard dataToText transformation. Or you can make your own format object with custom dataToText method.
Alex (ActiveWidgets)
October 17,

This topic is archived.

See also:


Back to support forum