setCellText method used can cause setCellText by col to FAIL

In almost all of Alex's demos he uses the obj.setCellText( function...) method to read (or generate) the initial sell settings. I noticed that almost every time I tried the very same demos, or something like it, the code would FAIL. It turns out (as least I think unless I'm doing something really wrong ) that:

If you use:
obj.setCellText(function(c,r){return myData[r][c]} );
Then Column "setCellText('"newtext",1) will work fine.

BUT if you use:
Then either a function type or simple "setCellText('"newtext",1) will not work.

Here is a full tiny example where you can choose by comment the type of set cell set: ( 2.0RC1 )
Can some one confirm this? (or tell me gently what I'm doing wrong?

    <script src="runtime/lib/aw.js"></script> 
    <link href="runtime/styles/xp/aw.css" rel="stylesheet"></link> 
</head> <body> 


    var myData = [ 
        ["aa","USPS ","0","9"], 
    var obj = new AW.UI.Grid;
// *******  SIMPLY comment one way of reading data and put in the other!!!
// *******  NOTE: complete array method Makes Setting  TEXT by column NOT work!

    obj.setCellText(function(c,r){return myData[r][c]} ); 






I think a lot of people noticed this when they tried Alex's beautiful checkbox demo. Where setting by column is common. But no where, could i find the reason. If this is a well know bug, could some one point to the description?

thanks everyone

G. Cayman
February 10,
Hi Geoff,

I don't know anything about this .... however I tried your example and can confirm that the problem still exists in 2.0 final.
Rob Francis
February 10,
Thanks Rob, I noticed way back on one of your posts, you saying that when you tired Alex's Checkbox example, it failed on REAL JS data sets.
I've been struggling for a while now, never able to get several OBVIOUSLY easy/simple demos to work, once I added a real JS array! I finally made a test that confirms the suspected problem. If true it may explain a lot of people's frustration.

I sure hope this is not a FEATURE and I'm just missing the point!

thanks all
G. Cayman
February 10,
I tried out your demo and this is what I see, let me know if it jives with what you see.

1) If you set your data using a function {obj.setCellText(function(c,r){return myData[r][c]} );}, both column and cell changes work fine:
setCellText("text", column) -> works fine
setCellText("text", column, row) -> works fine

2) If you use the array method to set your data {setCellText(arrayName)} then you can only change single cell values, not an entire column at once:
setCellText("text", column) -> does not work
setCellText("text", column, row) - still works fine

In both cases, I was setting the cells to their new values after the grid was rendered. This is how it would be used in the real world. I think if you are trying to change the values of columns more then once before a grid is rendered then you have some fine tuning to do in your program.

So in my opinion, this looks like a bug. I would think that you should be able to change cell or column values at will regrdless of how you put the original data into the grid.
Jim Hunter (www.FriendsOfAW.com)
February 10,
This behavior is 'by design', however I see that most people expect different behavior, so this might be a wrong design (=bug).

In the current implementation the priority is determined by 'precision', i.e. whether you have specified 0, 1 or 2 indices. For example, setting the value to one cell (2 indices) overwrites the default value for the column (1 index) and default value for the column overwrites the grid default (0 index).

The non-trivial point here is that assigning a two-dimensional array is equivalent to specifying 2 indices because you provide unique exact value for each cell. As a result it takes priority over any other method.

However assigning a function also behaves depending on the specificity of assignment (and not the number of function arguments!). So when you assign a function to all cells - it is the same as 'default' value (lowest priority) and will be overwritten by column or cell assignment. Of course, you can assign a function to just one column or just one cell and in this case the priority will be different (higher).

What I see from this and previous discussions is that more natural algorithm would be where the latest assigment always has higher priority. What do you think?
Alex (ActiveWidgets)
February 10,
I agree, last assigned = highest priority. Thanks for the detailed explanation.
Jim Hunter (www.FriendsOfAW.com)
February 10,
I am very sorry, I dont fully understand the ramifacations of your rule?
Why if you assign a complete array, does it overide the Column set rule but NOT the CELL set rule, seems by that rule neither should work, again what am i missing?

Once we get past the above; we of course we have to get to what happens when you assign TEXT (from an array) (function method) that contains a checkbox, then try to put 'your famous set yes:no' function into the text value. Seems that it just BLOWS up...???? WHY?

ok ok forget that one, first paragraph first!!!!


G Cayman
February 10,
I want my data to be formatted such that some columns would be dependent on other columns
I want to do calculations like columnA+columnB=columnC

Is it possible with ActiveWidgets?
Please help as this appears very critical for us.
Fidelity India
June 23,
I just found this discussion after spending another hour apprently running into my own version of the above problem.

Alex, has anything changed since February?

My grid consists of some data that would pulled from a SQL query to be displayed and edited by the user. I would like a calculated column. But if I put all the data first in as a big JS array, then according to your specificity hierarchy approach I can't then set up a column to handle a live calculation via SetCellFormat or SetCellData..because it's only "column-level" and I've already put in "cell-level" data.

I suppose I could set every cell in that column to handle a calculation, but that doesn't sound like a good way to handle it.

I guess I can try to do the calculations in a generalized cell validation routine. Might even be efficient. Hmmm..

Anything I'm missing? A way to clear out the cell-sepcific values for a column?


Larry Groebe
August 21,

This topic is archived.

See also:

Back to support forum