:: Forum >>

Calc Columns - Suppress Zeros

Using the calculated columns patch I am calculating a nett total figure across a row within a grid.

This works fine, my problem is when I scroll up and down the grid my function kicks in and returns zero's.. Can I suppress them in any way or can my code be made more efficient??

Here's the code

//Calcuation for line totals
obj.onCellValueChanged = function(value, col, row){
if(col==1 || col==2 || col==3){

var t=type.getControlText();

if (t=='SI')
{obj.setCellFormula('(((column(1)/100)*column(3)-column(1))*column(2))*-1', 4);} // calc line total in column-4
else {obj.setCellFormula('(((column(1)/100)*column(3)-column(1))*column(2))', 4);} // calc line total in column-4
                                    
                                    obj.setCellData(NettTotal,6, 50);
obj.setCellData(VatTotal,6, 51);
obj.setCellData(Total,6, 52);
                                    obj.setCellText(VAT.getControlText(),6,row);
obj.setCellText(cent.getControlText(),5,row);
var nettrefresh = obj.getCellText(6, 50);
var vatrefresh = obj.getCellText(6, 51);
var totalrefresh = obj.getCellText(6, 52);
var discrefresh = obj.getCellText(6, 53);
                                    nett.setControlText(nettrefresh);
vat.setControlText(vatrefresh);
total.setControlText(totalrefresh);
disc.setControlText(discrefresh);
nett.refresh();
vat.refresh();
total.refresh();
disc.refresh();
}
}


Also is the calculated columns patch now put of the library?? if so I can reduce some of my code...
Jez
Tuesday, December 8, 2009
When you call obj.setCellFormula('...', colIndex) - you are assigning the function to the whole column (all rows). If you want to assign it to one row you should use rowIndex as well - obj.setCellFormula('...', colIndex, rowIndex). Probably this is why you see zeros in other rows.

cell formula is not part of the package, I guess you took the code from here -

http://www.activewidgets.com/javascript.forum.20911.7/calculated-columns-cell-formula.html
Alex (ActiveWidgets)
Friday, December 11, 2009
Thanks Alex, it was that easy! For some reason I thought you couldn't assign a rowIndex because I the post where I got the patch from didn't show it...




Jez
Friday, December 11, 2009

This topic is archived.


Back to support forum

Forum search