3.2.0

calc columns using cell formulas

Is anyone using the patch referenced here:

/javascript.forum.20911.0/calculated-columns-cell-formula.html

I really need to do formulas but I'm having no success yet. Any examples or confirmation that it can be done, would be greatly appreciated!
beth
July 14,
I see now that it DOES work.

My problem was placing

grid.setCellData(myCells2);

after

grid.setCellFormula('myFunction(column(0))', 1);

Moving setCellData helped here as well as when I could not get date sorting to work. Moving setCellData above the column definitions fixed that. Not sure if that's an obvious thing to most users, but I will put it out there just in case. ;-)
beth
July 15,
I have created a calculated column where date values are generated. I send a date column and an integer column to the formula:

grid2.setCellFormula("myFunction(column(4),column(6))",16);

As an example, say that column(4)=03/02/12.

function myFunction(a,b)
{
alert("a: " + a); [shows 1330747200000]
var dDate = new Date(a);
alert("dDate: " + dDate); [shows Fri Mar 2 23:00:00 EST 2012]

return dDate;
}

The calculated column then displays undefined/undefined/undefined. So I need to return the result in the same format which the function received the date value, but I have no idea what 1330747200000 is. I thought maybe it was like a Julian date, but the online converters don't give me anything close to the March 2, 2012 date. Any help or hints would be huge.
beth
July 15,
I took the date format off the cell, do the calculations, and pass it back as a string. That seems to work.
beth
July 16,
The formula re-calculates for every column in the grid. Is there any way to limit the calculation to only the column that displays the results?

I wouldn't care except there is a noticeable time lag. I could improve it a lot by calculating only once.

But I don't see a way to pass the row/column to a calculated column formula, as in a defineCellProperty.
beth
July 18,
Not important now ... I eliminated some unnecessary database queries and it's fine.
beth
July 18,

This topic is archived.

See also:


Back to support forum