ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: joaosales on March 19, 2018, 03:44:22 pm

Title: Using Formulas in multiple Columns
Post by: joaosales on March 19, 2018, 03:44:22 pm
Hi,

is there a way to set a set the same formula as dataIndx for multiple columns, but have the formula use a condition depending on the column?
example:
Code: [Select]
["RandomFormula", function(ui){

                    var total = 0;

                    for (var k in ui) {

                        if (!isNaN(ui[k])) {
                            if (k.indexOf("-") > 0) total += ui[k];
                        }
                    }
                   if(column X) total = total/10;
                   if(column Y) total = total*10;
}]

I'm trying to build the table dynamically , so i would need extra information about the column, other than the dataIndx, to know how to calculate.

Thanks,
Title: Re: Using Formulas in multiple Columns
Post by: paramvir on March 19, 2018, 09:43:14 pm
Same function can be used for multiple formulas by using a named function instead of anonymous function.

Code: [Select]
[[dataIndx1, fn], [dataIndx2, fn2],...]

2nd parameter to the function is column which can help you get column specific information inside the function.

Code: [Select]
function fn(rowData, column){
 ..
}