Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Using javascript to change aggregate function in table
djatnieks
I have a report design that defines a table group and in the table footer there is a column that aggregates on that group.
The report design defines the aggregation function as "Sum" and I would like to change the function using javascript. Are there any examples of how I can do this??
For context, in the report designer UI the "Aggreagation Builder" dialog shows "Column Binding Name", "Display Name", "Data Type", "Function", etc. I would like to change the "Function" value dynamically using javascript. An example of how this can be done would be great.
thanks,
dan
Find more posts tagged with
Comments
djatnieks
Okay, well by trial and error I have found the following:
If I add an "onPrepare" script for my Table element, I am able to change the aggregation function using the following javascript:
var tableAggFunc = "Sum";
this.getDataBindings()[2].getStructure().setProperty("aggregateFunction", tableAggFunc);
This works, but it isn't pretty and I found it after much guessing.
In particular, using "getDataBindings()[2]" to access the data binding isn't very safe. I found the correct index value of 2 in my case by looking at the rptdesign file itself and counting to the correct "<structure>" entry.
I would like to be able to index the data bindings by name, but the "getDataBindings(string)" function definition returns a String result instead of an object so it's a dead end.
I also cannot find a "getProperty(string, string)" function signature that is similar to the "setProperty(string, string)" function that I used. Instead there is a getProperty(Module, String) -- but I don't know what a "Module" is.
I also tried adding a script to the specific Data element, however "this.getDataBindings()" returns an empty array.
Any further enlightenment would be much appreciated.
zmirovic
I have same situation here. Calling this code:
this.getDataBindings()[index].getStructure().setProperty("aggregateFunction", fuctionName);
is working, but must be much nicer solution. Anyone knows how?
There is also this.getDataBinding(String) but that returns null for existing binding name. On the other side, this.removeDataBinding(String) working like expected.